コード例 #1
0
        public async Task <bool> Handle(UpdateGatewayReviewStatusAsClarificationRequest request, CancellationToken cancellationToken)
        {
            var application = await _applyRepository.GetApplication(request.ApplicationId);

            if (application == null)
            {
                return(false);
            }

            if (application.ApplyData == null)
            {
                application.ApplyData = new ApplyData();
            }

            if (application.ApplyData.GatewayReviewDetails == null)
            {
                application.ApplyData.GatewayReviewDetails = new ApplyGatewayDetails();
            }

            application.ApplyData.GatewayReviewDetails.ClarificationRequestedOn = DateTime.UtcNow;
            application.ApplyData.GatewayReviewDetails.ClarificationRequestedBy = request.UserId;

            return(await _gatewayRepository.UpdateGatewayReviewStatusAndComment(request.ApplicationId,
                                                                                application.ApplyData, GatewayReviewStatus.ClarificationSent, request.UserId, request.UserName));
        }
        public async Task <bool> Handle(UpdateGatewayReviewStatusAndCommentCommand request, CancellationToken cancellationToken)
        {
            _auditService.StartTracking(UserAction.UpdateGatewayReviewStatus, request.UserId, request.UserName);

            var application = await _applyRepository.GetApplication(request.ApplicationId);

            if (application?.ApplyData == null)
            {
                throw new InvalidOperationException($"Application {request.ApplicationId} not found");
            }
            else if (application.ApplyData.GatewayReviewDetails == null)
            {
                application.ApplyData.GatewayReviewDetails = new ApplyGatewayDetails();
            }

            _auditService.AuditUpdate(application);

            application.ApplicationStatus   = request.GatewayReviewStatus == GatewayReviewStatus.Rejected ? ApplicationStatus.Rejected : ApplicationStatus.GatewayAssessed;
            application.GatewayReviewStatus = request.GatewayReviewStatus;

            application.ApplyData.GatewayReviewDetails.OutcomeDateTime     = DateTime.UtcNow;
            application.ApplyData.GatewayReviewDetails.Comments            = request.GatewayReviewComment;
            application.ApplyData.GatewayReviewDetails.ExternalComments    = request.GatewayReviewExternalComment;
            application.ApplyData.GatewayReviewDetails.SubcontractingLimit = request.SubcontractingLimit;

            var updatedSuccessfully = await _gatewayRepository.UpdateGatewayReviewStatusAndComment(application.ApplicationId, application.ApplyData, application.GatewayReviewStatus, request.UserId, request.UserName);


            if (updatedSuccessfully && request.GatewayReviewStatus == GatewayReviewStatus.Rejected)
            {
                var oversightReview = new OversightReview
                {
                    ApplicationId    = request.ApplicationId,
                    Status           = OversightReviewStatus.Rejected,
                    UserId           = request.UserId,
                    UserName         = request.UserName,
                    InternalComments = request.GatewayReviewComment,
                    ExternalComments = request.GatewayReviewExternalComment
                };

                _auditService.AuditInsert(oversightReview);
                _oversightReviewRepository.Add(oversightReview);

                await _applicationUpdatedEmailService.SendEmail(request.ApplicationId);
            }

            _auditService.Save();
            await _unitOfWork.Commit();

            return(updatedSuccessfully);
        }
        public async Task <bool> Handle(UpdateGatewayReviewStatusAsClarificationRequest request, CancellationToken cancellationToken)
        {
            _auditService.StartTracking(UserAction.UpdateGatewayReviewStatus, request.UserId, request.UserName);

            var application = await _applyRepository.GetApplication(request.ApplicationId);

            if (application == null)
            {
                return(false);
            }

            _auditService.AuditUpdate(application);

            application.ApplicationStatus   = ApplicationStatus.Submitted;
            application.GatewayReviewStatus = GatewayReviewStatus.ClarificationSent;

            if (application.ApplyData == null)
            {
                application.ApplyData = new ApplyData();
            }

            if (application.ApplyData.GatewayReviewDetails == null)
            {
                application.ApplyData.GatewayReviewDetails = new ApplyGatewayDetails();
            }

            application.ApplyData.GatewayReviewDetails.ClarificationRequestedOn = DateTime.UtcNow;
            application.ApplyData.GatewayReviewDetails.ClarificationRequestedBy = request.UserId;

            var updatedSuccessfully = await _gatewayRepository.UpdateGatewayReviewStatusAndComment(request.ApplicationId,
                                                                                                   application.ApplyData, application.GatewayReviewStatus, request.UserId, request.UserName);

            _auditService.Save();
            await _unitOfWork.Commit();

            return(updatedSuccessfully);
        }