|
|
|
@ -11,20 +11,20 @@ namespace WF_WebAdmin.Service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Asynchronously adds a new quote to the database and returns the corresponding <see cref="QuoteDTO"/>.
|
|
|
|
|
/// Asynchronously adds a new quote to the database and returns the corresponding <see cref="QuoteDto"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="quote">The <see cref="Quote"/> object to be added to the database.</param>
|
|
|
|
|
/// <returns>A task representing the asynchronous operation, with a <see cref="QuoteDTO"/> result containing the added quote's data.</returns>
|
|
|
|
|
/// <returns>A task representing the asynchronous operation, with a <see cref="QuoteDto"/> result containing the added quote's data.</returns>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// This method converts the provided <see cref="Quote"/> object into a <see cref="QuoteDTO"/> using <see cref="QuoteExtension"/>.
|
|
|
|
|
/// This method converts the provided <see cref="Quote"/> object into a <see cref="QuoteDto"/> using <see cref="QuoteExtension"/>.
|
|
|
|
|
/// It then inserts the quote into the PostgreSQL database using a parameterized SQL query with the help of Npgsql.
|
|
|
|
|
/// After successfully inserting the quote, the corresponding <see cref="QuoteDTO"/> is returned to the caller.
|
|
|
|
|
/// After successfully inserting the quote, the corresponding <see cref="QuoteDto"/> is returned to the caller.
|
|
|
|
|
/// Error handling is in place to catch any issues during the database insertion process, with the exception message logged in case of failure.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
public async Task<QuoteDTO> AddQuoteAsync(Quote quote)
|
|
|
|
|
public async Task<QuoteDto> AddQuoteAsync(Quote quote)
|
|
|
|
|
{
|
|
|
|
|
QuoteExtension extension = new QuoteExtension();
|
|
|
|
|
QuoteDTO quoteDTO = extension.QuoteToDTO(quote);
|
|
|
|
|
QuoteDto quoteDTO = extension.QuoteToDTO(quote);
|
|
|
|
|
|
|
|
|
|
// Utilisation de NpgsqlConnection pour PostgreSQL
|
|
|
|
|
using (var connection = new NpgsqlConnection(_connectionString))
|
|
|
|
@ -75,12 +75,12 @@ namespace WF_WebAdmin.Service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Asynchronously handles the removal of a quote and returns the corresponding <see cref="QuoteDTO"/>.
|
|
|
|
|
/// Asynchronously handles the removal of a quote and returns the corresponding <see cref="QuoteDto"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="quote">The <see cref="Quote"/> object to be removed.</param>
|
|
|
|
|
/// <returns>A task representing the asynchronous operation, with a <see cref="QuoteDTO"/> result corresponding to the removed quote.</returns>
|
|
|
|
|
/// <returns>A task representing the asynchronous operation, with a <see cref="QuoteDto"/> result corresponding to the removed quote.</returns>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// This method takes a <see cref="Quote"/> object, converts it into a <see cref="QuoteDTO"/> using the
|
|
|
|
|
/// This method takes a <see cref="Quote"/> object, converts it into a <see cref="QuoteDto"/> using the
|
|
|
|
|
/// <see cref="QuoteExtension"/>, and then returns the DTO. Note that while this function is named `RemoveQuote`,
|
|
|
|
|
/// it currently only converts the quote to a DTO and does not actually perform any database removal operation.
|
|
|
|
|
/// You may need to implement additional logic to remove the quote from the database.
|
|
|
|
@ -88,7 +88,7 @@ namespace WF_WebAdmin.Service
|
|
|
|
|
public Task RemoveQuote(Quote quote)
|
|
|
|
|
{
|
|
|
|
|
QuoteExtension extension = new QuoteExtension();
|
|
|
|
|
QuoteDTO quoteDTO = extension.QuoteToDTO(quote);
|
|
|
|
|
QuoteDto quoteDTO = extension.QuoteToDTO(quote);
|
|
|
|
|
|
|
|
|
|
// Return the DTO as the result of this asynchronous operation (though no removal logic is currently implemented)
|
|
|
|
|
return Task.FromResult(quoteDTO);
|
|
|
|
@ -96,12 +96,12 @@ namespace WF_WebAdmin.Service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Asynchronously validates a quote and returns the corresponding <see cref="QuoteDTO"/>.
|
|
|
|
|
/// Asynchronously validates a quote and returns the corresponding <see cref="QuoteDto"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="quote">The <see cref="Quote"/> object to be validated.</param>
|
|
|
|
|
/// <returns>A task representing the asynchronous operation, with a <see cref="QuoteDTO"/> result corresponding to the validated quote.</returns>
|
|
|
|
|
/// <returns>A task representing the asynchronous operation, with a <see cref="QuoteDto"/> result corresponding to the validated quote.</returns>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// This method takes a <see cref="Quote"/> object, converts it into a <see cref="QuoteDTO"/> using the
|
|
|
|
|
/// This method takes a <see cref="Quote"/> object, converts it into a <see cref="QuoteDto"/> using the
|
|
|
|
|
/// <see cref="QuoteExtension"/>, and returns the DTO. The method is named `validQuote`, but currently, it only
|
|
|
|
|
/// converts the quote into a DTO and does not perform any actual validation logic.
|
|
|
|
|
/// If you intend to validate the quote (e.g., updating its status in a database), you will need to implement
|
|
|
|
@ -110,7 +110,7 @@ namespace WF_WebAdmin.Service
|
|
|
|
|
public Task validQuote(Quote quote)
|
|
|
|
|
{
|
|
|
|
|
QuoteExtension extension = new QuoteExtension();
|
|
|
|
|
QuoteDTO quoteDTO = extension.QuoteToDTO(quote);
|
|
|
|
|
QuoteDto quoteDTO = extension.QuoteToDTO(quote);
|
|
|
|
|
|
|
|
|
|
// Return the DTO as the result of this asynchronous operation (though no validation logic is currently implemented)
|
|
|
|
|
return Task.FromResult(quoteDTO);
|
|
|
|
@ -118,12 +118,12 @@ namespace WF_WebAdmin.Service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Asynchronously updates a quote and returns the corresponding <see cref="QuoteDTO"/>.
|
|
|
|
|
/// Asynchronously updates a quote and returns the corresponding <see cref="QuoteDto"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="quote">The <see cref="Quote"/> object to be updated.</param>
|
|
|
|
|
/// <returns>A task representing the asynchronous operation, with a <see cref="QuoteDTO"/> result corresponding to the updated quote.</returns>
|
|
|
|
|
/// <returns>A task representing the asynchronous operation, with a <see cref="QuoteDto"/> result corresponding to the updated quote.</returns>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// This method takes a <see cref="Quote"/> object, converts it into a <see cref="QuoteDTO"/> using the
|
|
|
|
|
/// This method takes a <see cref="Quote"/> object, converts it into a <see cref="QuoteDto"/> using the
|
|
|
|
|
/// <see cref="QuoteExtension"/>, and returns the DTO. The method is named `updateQuote`, but currently, it only
|
|
|
|
|
/// converts the quote into a DTO and does not perform any actual update logic.
|
|
|
|
|
/// If you intend to update the quote (e.g., modifying the quote in a database or data source),
|
|
|
|
@ -132,7 +132,7 @@ namespace WF_WebAdmin.Service
|
|
|
|
|
public Task updateQuote(Quote quote)
|
|
|
|
|
{
|
|
|
|
|
QuoteExtension extension = new QuoteExtension();
|
|
|
|
|
QuoteDTO quoteDTO = extension.QuoteToDTO(quote);
|
|
|
|
|
QuoteDto quoteDTO = extension.QuoteToDTO(quote);
|
|
|
|
|
|
|
|
|
|
// Return the DTO as the result of this asynchronous operation (though no update logic is currently implemented)
|
|
|
|
|
return Task.FromResult(quoteDTO);
|
|
|
|
|