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); }
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); }
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); }
public async Task <bool> Handle(RecordOversightOutcomeCommand request, CancellationToken cancellationToken) { _logger.LogInformation($"Recording Oversight review status of {request.OversightStatus} for application Id {request.ApplicationId}"); _auditService.StartTracking(UserAction.RecordOversightOutcome, request.UserId, request.UserName); var application = await GetApplicationOrThrow(request.ApplicationId); var(oversightReview, isNew) = await GetExistingOrNewOversightReview(request.ApplicationId); ApplyChanges(oversightReview, request, isNew); SaveChanges(oversightReview, application, isNew); _auditService.Save(); await _unitOfWork.Commit(); await _applicationUpdatedEmailService.SendEmail(request.ApplicationId); return(true); }