Example #1
0
        public async Task <Unit> Handle(MakeAppealCommand request, CancellationToken cancellationToken)
        {
            var oversightReview = await _oversightReviewRepository.GetByApplicationId(request.ApplicationId);

            VerifyOversightReviewIsUnsuccessfulOrRemoved(oversightReview);

            var currentAppeal = await _appealRepository.GetByApplicationId(request.ApplicationId);

            VerifyAppealNotSubmitted(currentAppeal);

            _auditService.StartTracking(UserAction.MakeAppeal, request.UserId, request.UserName);

            if (currentAppeal is null)
            {
                currentAppeal = new Appeal
                {
                    ApplicationId                = request.ApplicationId,
                    Status                       = AppealStatus.Submitted,
                    AppealSubmittedDate          = DateTime.UtcNow,
                    HowFailedOnPolicyOrProcesses = request.HowFailedOnPolicyOrProcesses,
                    HowFailedOnEvidenceSubmitted = request.HowFailedOnEvidenceSubmitted,
                    UserId                       = request.UserId,
                    UserName                     = request.UserName,
                };

                _auditService.AuditInsert(currentAppeal);
                _appealRepository.Add(currentAppeal);
            }
            else
            {
                _auditService.AuditUpdate(currentAppeal);

                currentAppeal.Status = AppealStatus.Submitted;
                currentAppeal.AppealSubmittedDate          = DateTime.UtcNow;
                currentAppeal.HowFailedOnPolicyOrProcesses = request.HowFailedOnPolicyOrProcesses;
                currentAppeal.HowFailedOnEvidenceSubmitted = request.HowFailedOnEvidenceSubmitted;
                currentAppeal.UserId    = request.UserId;
                currentAppeal.UserName  = request.UserName;
                currentAppeal.UpdatedOn = DateTime.UtcNow;

                _appealRepository.Update(currentAppeal);
            }

            _auditService.Save();

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

            if (!(application.ApplicationStatus == ApplicationStatus.Unsuccessful && appeal.Status == AppealStatus.Unsuccessful))
            {
                _auditService.AuditUpdate(application);
            }

            switch (appeal.Status)
            {
            case AppealStatus.InProgress:
                application.ApplicationStatus = ApplicationStatus.InProgressAppeal;
                break;

            case AppealStatus.Successful:
            case AppealStatus.SuccessfulAlreadyActive:
            case AppealStatus.SuccessfulFitnessForFunding:
                if (application.GatewayReviewStatus == GatewayReviewStatus.Fail)
                {
                    application.ApplicationStatus = ApplicationStatus.AppealSuccessful;
                }
                else
                {
                    application.ApplicationStatus = ApplicationStatus.Successful;
                }
                break;

            case AppealStatus.Unsuccessful:
                application.ApplicationStatus = ApplicationStatus.Unsuccessful;
                break;
            }

            _applyRepository.Update(application);
            _applicationUpdatedEmailService.SendEmail(appeal.ApplicationId);
        }