Example #1
0
        public async Task <Unit> Handle(RecordOversightGatewayRemovedOutcomeCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Recording Oversight review status of Unsuccessful for gateway removed application Id {request.ApplicationId}");

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

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

            var oversightReview = new OversightReview
            {
                ApplicationId = request.ApplicationId,
                Status        = OversightReviewStatus.Removed,
                UserId        = request.UserId,
                UserName      = request.UserName,
            };

            _auditService.StartTracking(UserAction.RecordOversightGatewayRemovedOutcome, request.UserId, request.UserName);
            _auditService.AuditInsert(oversightReview);

            _oversightReviewRepository.Add(oversightReview);

            _auditService.Save();

            await _unitOfWork.Commit();

            await _applicationUpdatedEmailService.SendEmail(request.ApplicationId);

            return(Unit.Value);
        }
Example #2
0
        private void SaveChanges(OversightReview oversightReview, Domain.Entities.Apply application, bool isNew)
        {
            if (isNew)
            {
                _oversightReviewRepository.Add(oversightReview);
            }
            else
            {
                _oversightReviewRepository.Update(oversightReview);
            }

            switch (oversightReview.Status)
            {
            case OversightReviewStatus.InProgress:
                application.ApplicationStatus = ApplicationStatus.InProgressOutcome;
                break;

            case OversightReviewStatus.Successful:
            case OversightReviewStatus.SuccessfulAlreadyActive:
            case OversightReviewStatus.SuccessfulFitnessForFunding:
                application.ApplicationStatus = ApplicationStatus.Successful;
                break;

            case OversightReviewStatus.Unsuccessful:
                application.ApplicationStatus = application.GatewayReviewStatus == GatewayReviewStatus.Rejected
                        ? ApplicationStatus.Rejected :
                                                ApplicationStatus.Unsuccessful;
                break;
            }

            _applyRepository.Update(application);
        }
        public async Task <bool> Handle(WithdrawApplicationCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Performing Withdraw Application action for ApplicationId: {request.ApplicationId}");

            var oversightReview = new OversightReview
            {
                ApplicationId    = request.ApplicationId,
                Status           = OversightReviewStatus.Withdrawn,
                InternalComments = request.Comments,
                UserId           = request.UserId,
                UserName         = request.UserName
            };

            var result = await _gatewayRepository.WithdrawApplication(request.ApplicationId, request.Comments, request.UserId, request.UserName);

            try
            {
                if (result)
                {
                    await _applicationUpdatedEmailService.SendEmail(request.ApplicationId);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Unable to send withdraw confirmation email for application: {request.ApplicationId}");
            }

            _auditService.StartTracking(UserAction.WithdrawApplication, request.UserId, request.UserName);
            _auditService.AuditInsert(oversightReview);
            _oversightReviewRepository.Add(oversightReview);
            _auditService.Save();

            return(result);
        }
        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);
        }
Example #5
0
        private void SaveChanges(OversightReview oversightReview, Domain.Entities.Apply application, bool isNew)
        {
            if (isNew)
            {
                _oversightReviewRepository.Add(oversightReview);
            }
            else
            {
                _oversightReviewRepository.Update(oversightReview);
            }

            if (oversightReview.Status == OversightReviewStatus.InProgress)
            {
                return;
            }

            application.ApplicationStatus = oversightReview.Status == OversightReviewStatus.Unsuccessful
                ? ApplicationStatus.Rejected
                : ApplicationStatus.Approved;

            _applyRepository.Update(application);
        }