コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }