コード例 #1
0
        public async Task <IEnumerable <ClaimAttachment> > Handle(FetchClaimAttachmentsByClaimIdRequest request, CancellationToken cancellationToken)
        {
            return(await Task.Run(() =>
            {
                var claimAttachments =
                    this.cloudPocClaimsDatabase
                    .ExecuteQueryProcedure <ClaimAttachmentRecord>(
                        CloudPocClaimsDatabaseProcedures.FetchClaimAttachmentsByClaimId,
                        request,
                        cancellationToken)
                    .Select(c => c.ToClaimAttachment());

                return claimAttachments;
            }));
        }
コード例 #2
0
        public async Task <Claim> Handle(FetchClaimByClaimIdRequest request, CancellationToken cancellationToken)
        {
            return(await Task.Run(() =>
            {
                var claimRecord =
                    this.cloudPocClaimsDatabase
                    .ExecuteQueryProcedure <ClaimRecord>(
                        CloudPocClaimsDatabaseProcedures.FetchClaimFlightByClaimId,
                        request,
                        cancellationToken)
                    .FirstOrDefault();

                if (claimRecord == null || cancellationToken.IsCancellationRequested)
                {
                    return null;
                }

                var claim = claimRecord.ToClaim();

                if (request.Flags.HasFlag(FetchClaimRequestFlags.WithClaimAttachments) && !cancellationToken.IsCancellationRequested)
                {
                    var fetchClaimAttachmentRequests = new FetchClaimAttachmentsByClaimIdRequest(request.ClaimId);
                    var claimAttachments = this.mediator.Send(fetchClaimAttachmentRequests);
                    claim.ClaimAttachments = claimAttachments.Result;
                }

                if (request.Flags.HasFlag(FetchClaimRequestFlags.WithClaimCosts) && !cancellationToken.IsCancellationRequested)
                {
                    var withAttachments = request.Flags.HasFlag(FetchClaimRequestFlags.WithClaimCostAttachments);
                    var fetchClaimCostRequests = new FetchClaimCostsByClaimIdRequest(request.ClaimId, withAttachments);
                    var claimCosts = this.mediator.Send(fetchClaimCostRequests);
                    claim.ClaimCosts = claimCosts.Result;
                }

                return claim;
            }));
        }