public async Task <Unit> Handle(DeleteClaimCommand request, CancellationToken cancellationToken) { var claimDocument = await _cosmosDbClaimDocumentService.GetItemAsync(request.Id); if (claimDocument == null) { throw new NotFoundException(nameof(ClaimDocument), request.Id); } await _cosmosDbClaimDocumentService.DeleteItemAsync(request.Id); var claimChangeNotification = new ClaimChangeEventNotification() { ClaimAudit = new ClaimAudit() { Id = Convert.ToInt32(request.Id), Name = claimDocument.Name, Year = claimDocument.Year, DamageCost = Convert.ToDecimal(claimDocument.DamageCost), Type = claimDocument.Type, CreatedAt = claimDocument.CreatedAt, RequestName = "Delete Claim" } }; await _mediator.Publish(claimChangeNotification); return(Unit.Value); }
public async Task <ClaimDocument> Handle(GetClaimByIdQuery request, CancellationToken cancellationToken) { var claim = await _cosmosDbClaimDocumentService.GetItemAsync(request.Id); if (claim == null) { throw new NotFoundException(nameof(ClaimDocument), request.Id); } return(claim); }