コード例 #1
0
        public async Task <string> Handle(ProcessSupportsCommand cmd)
        {
            if (string.IsNullOrEmpty(cmd.FileId))
            {
                throw new ArgumentNullException(nameof(cmd.FileId));
            }
            if (string.IsNullOrEmpty(cmd.RequestingUserId))
            {
                throw new ArgumentNullException(nameof(cmd.RequestingUserId));
            }

            //verify no paper supports included
            var paperReferrals = cmd.Supports.Where(s => s is Referral r && r.IsPaperReferral).Cast <Referral>().Select(r => r.ExternalReferenceId).ToArray();

            if (paperReferrals.Any())
            {
                throw new BusinessValidationException($"file {cmd.FileId} error: cannot process paper referrals {string.Join(',', paperReferrals)} as digital");
            }

            var requestingUser = (await teamRepository.GetMembers(userId: cmd.RequestingUserId, includeStatuses: activeOnlyStatus)).Cast <Resources.Teams.TeamMember>().Single();

            foreach (var support in cmd.Supports)
            {
                support.CreatedBy = new Shared.Contracts.Events.TeamMember {
                    Id = requestingUser.Id
                };
                support.CreatedOn = DateTime.UtcNow;
            }

            //Not ideal solution - the IDs are concatenated by CaseRepository to ensure
            //all supports are created in a single transaction
            var supportIds = (await caseRepository.ManageCase(new SaveEvacuationFileSupportCommand
            {
                FileId = cmd.FileId,
                Supports = mapper.Map <IEnumerable <Resources.Cases.Evacuations.Support> >(cmd.Supports)
            })).Id.Split(';');

            var printRequestId = await printingRepository.Manage(new SavePrintRequest
            {
                PrintRequest = new ReferralPrintRequest
                {
                    FileId           = cmd.FileId,
                    SupportIds       = supportIds,
                    IncludeSummary   = cmd.IncludeSummaryInReferralsPrintout,
                    RequestingUserId = requestingUser.Id,
                    Type             = ReferralPrintType.New,
                    Comments         = "Process supports"
                }
            });

            return(printRequestId);
        }
コード例 #2
0
        public async Task <string> Handle(ProcessSupportsCommand cmd)
        {
            if (string.IsNullOrEmpty(cmd.FileId))
            {
                throw new ArgumentNullException(nameof(cmd.FileId));
            }
            if (string.IsNullOrEmpty(cmd.RequestingUserId))
            {
                throw new ArgumentNullException(nameof(cmd.RequestingUserId));
            }

            var requestingUser = (await teamRepository.GetMembers(userId: cmd.RequestingUserId)).Cast <Resources.Team.TeamMember>().Single();

            //Not ideal solution - the IDs are concatenated by CaseRepository to ensure
            //all supports are created in a single transaction
            var supportIds = (await caseRepository.ManageCase(new SaveEvacuationFileSupportCommand
            {
                FileId = cmd.FileId,
                Supports = mapper.Map <IEnumerable <Resources.Cases.Support> >(cmd.supports)
            })).Id.Split(';');

            var referralPrintId = await printingRepository.Manage(new SavePrintRequest
            {
                PrintRequest = new ReferralPrintRequest
                {
                    FileId           = cmd.FileId,
                    SupportIds       = supportIds,
                    IncludeSummary   = cmd.IncludeSummaryInReferralsPrintout,
                    RequestingUserId = requestingUser.Id,
                    Type             = ReferralPrintType.New,
                    Comments         = "Process supports"
                }
            });

            return(referralPrintId);
        }