Skip to content

Commit

Permalink
Merge pull request #98 from SWD392-Domus/feature/quotations-management
Browse files Browse the repository at this point in the history
[Quotations mangement][Duy] Change quotation's status
  • Loading branch information
duykasama authored Mar 7, 2024
2 parents 649f356 + 659920d commit 233ec4c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Domus.Api/Controllers/QuotationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,12 @@ public async Task<IActionResult> GetQuotationRevision(Guid quotationId, Guid rev
async () => await _quotationService.GetQuotationRevision(quotationId, revisionId).ConfigureAwait(false)
).ConfigureAwait(false);
}

[HttpPut("{quotationId:guid}/status")]
public async Task<IActionResult> UpdateQuotationStatus(Guid quotationId, [FromBody] string status)
{
return await ExecuteServiceLogic(
async () => await _quotationService.UpdateQuotationStatus(quotationId, status).ConfigureAwait(false)
).ConfigureAwait(false);
}
}
11 changes: 11 additions & 0 deletions Domus.Service/Implementations/QuotationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,17 @@ public async Task<ServiceActionResult> GetQuotationRevision(Guid quotationId, Gu
return new ServiceActionResult(true) { Data = quotation };
}

public async Task<ServiceActionResult> 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<ServiceActionResult> DeleteQuotation(Guid id)
{
var quotation = await _quotationRepository.GetAsync(q => !q.IsDeleted && q.Id == id) ?? throw new QuotationNotFoundException();
Expand Down
1 change: 1 addition & 0 deletions Domus.Service/Interfaces/IQuotationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public interface IQuotationService : IAutoRegisterable
Task<ServiceActionResult> GetQuotationPriceChangeHistory(Guid quotationId);
Task<ServiceActionResult> GetQuotationRevisions(Guid id);
Task<ServiceActionResult> GetQuotationRevision(Guid quotationId, Guid revisionId);
Task<ServiceActionResult> UpdateQuotationStatus(Guid quotationId, string status);
}

0 comments on commit 233ec4c

Please sign in to comment.