diff --git a/Domus.Api/Controllers/QuotationsController.cs b/Domus.Api/Controllers/QuotationsController.cs index 9917840..8313cf3 100644 --- a/Domus.Api/Controllers/QuotationsController.cs +++ b/Domus.Api/Controllers/QuotationsController.cs @@ -146,4 +146,12 @@ public async Task GetQuotationRevision(Guid quotationId, Guid rev async () => await _quotationService.GetQuotationRevision(quotationId, revisionId).ConfigureAwait(false) ).ConfigureAwait(false); } + + [HttpPut("{quotationId:guid}/status")] + public async Task UpdateQuotationStatus(Guid quotationId, [FromBody] string status) + { + return await ExecuteServiceLogic( + async () => await _quotationService.UpdateQuotationStatus(quotationId, status).ConfigureAwait(false) + ).ConfigureAwait(false); + } } diff --git a/Domus.Service/Implementations/QuotationService.cs b/Domus.Service/Implementations/QuotationService.cs index 77df3cf..7d42798 100644 --- a/Domus.Service/Implementations/QuotationService.cs +++ b/Domus.Service/Implementations/QuotationService.cs @@ -279,6 +279,17 @@ public async Task GetQuotationRevision(Guid quotationId, Gu return new ServiceActionResult(true) { Data = quotation }; } + public async Task UpdateQuotationStatus(Guid quotationId, string status) + { + var quotation = await _quotationRepository.GetAsync(q => !q.IsDeleted && q.Id == quotationId) ?? throw new QuotationNotFoundException(); + quotation.Status = status; + + await _quotationRepository.UpdateAsync(quotation); + await _unitOfWork.CommitAsync(); + + return new ServiceActionResult(true); + } + public async Task DeleteQuotation(Guid id) { var quotation = await _quotationRepository.GetAsync(q => !q.IsDeleted && q.Id == id) ?? throw new QuotationNotFoundException(); diff --git a/Domus.Service/Interfaces/IQuotationService.cs b/Domus.Service/Interfaces/IQuotationService.cs index e576396..b95f284 100644 --- a/Domus.Service/Interfaces/IQuotationService.cs +++ b/Domus.Service/Interfaces/IQuotationService.cs @@ -23,4 +23,5 @@ public interface IQuotationService : IAutoRegisterable Task GetQuotationPriceChangeHistory(Guid quotationId); Task GetQuotationRevisions(Guid id); Task GetQuotationRevision(Guid quotationId, Guid revisionId); + Task UpdateQuotationStatus(Guid quotationId, string status); }