public async Task <IActionResult> ConfirmRemoveApplication(Guid applicationId, RoatpRemoveApplicationViewModel viewModel) { var application = await _applyApiClient.GetApplication(applicationId); if (application is null) { return(RedirectToAction(nameof(RoatpGatewayController.NewApplications), "RoatpGateway")); } else if (application.ApplicationStatus == ApplicationStatus.Removed) { return(RedirectToAction(nameof(RoatpGatewayController.ViewApplication), "RoatpGateway", new { applicationId })); } var validationResponse = await _removeApplicationValidator.Validate(viewModel); if (validationResponse.Errors != null && validationResponse.Errors.Any()) { _applicationActionsOrchestrator.ProcessRemoveApplicationViewModelOnError(viewModel, validationResponse); return(View("~/Views/Gateway/ConfirmRemoveApplication.cshtml", viewModel)); } else if (viewModel.ConfirmApplicationAction == HtmlAndCssElements.RadioButtonValueYes) { var username = HttpContext.User.UserDisplayName(); var userId = HttpContext.User.UserId(); await _applyApiClient.RemoveApplication(viewModel.ApplicationId, viewModel.OptionYesText, viewModel.OptionYesTextExternal, userId, username); viewModel.ApplicationReferenceNumber = application.ApplyData.ApplyDetails.ReferenceNumber; return(View("~/Views/Gateway/ApplicationRemoved.cshtml", viewModel)); } else { return(RedirectToAction(nameof(RoatpGatewayController.ViewApplication), "RoatpGateway", new { applicationId })); } }
public async Task <RoatpWithdrawApplicationViewModel> GetWithdrawApplicationViewModel(Guid applicationId, string userName) { RoatpWithdrawApplicationViewModel viewModel = null; var application = await _applyApiClient.GetApplication(applicationId); var contact = await _applyApiClient.GetContactDetails(applicationId); if (application != null && contact != null) { viewModel = new RoatpWithdrawApplicationViewModel { ApplicationId = application.ApplicationId, ApplicationStatus = application.ApplicationStatus, Ukprn = application.ApplyData.ApplyDetails.UKPRN, ApplyLegalName = application.ApplyData.ApplyDetails.OrganisationName, ApplicationRoute = application.ApplyData.ApplyDetails.ProviderRouteName, ApplicationReferenceNumber = application.ApplyData.ApplyDetails.ReferenceNumber, ApplicationEmailAddress = contact.Email, ApplicationSubmittedOn = application.ApplyData.ApplyDetails.ApplicationSubmittedOn }; } return(viewModel); }
public async Task <OutcomeApplicationViewModel> GetOverviewViewModel(GetOutcomeOverviewRequest request) { var application = await _applicationApiClient.GetApplication(request.ApplicationId); var contact = await _applicationApiClient.GetContactForApplication(request.ApplicationId); var sequences = await _clarificationApiClient.GetClarificationSequences(request.ApplicationId); if (application is null || contact is null || sequences is null) { return(null); } var viewmodel = new OutcomeApplicationViewModel(application, contact, sequences); var savedOutcomes = await _clarificationApiClient.GetAllClarificationPageReviewOutcomes(request.ApplicationId, request.UserId); if (!(savedOutcomes is null) && savedOutcomes.Any()) { foreach (var sequence in viewmodel.Sequences) { foreach (var section in sequence.Sections) { if (string.IsNullOrEmpty(section.Status)) { section.Status = OverviewStatusService.GetOutcomeSectionStatus(savedOutcomes, sequence.SequenceNumber, section.SectionNumber); } } } } return(viewmodel); }
public async Task <ModeratorReviewAnswersViewModel> GetReviewAnswersViewModel(GetReviewAnswersRequest request) { var application = await _applicationApiClient.GetApplication(request.ApplicationId); var contact = await _applicationApiClient.GetContactForApplication(request.ApplicationId); var moderatorPage = await _moderationApiClient.GetModeratorPage(request.ApplicationId, request.SequenceNumber, request.SectionNumber, request.PageId); if (application is null || contact is null || moderatorPage is null) { return(null); } var viewModel = new ModeratorReviewAnswersViewModel { ApplicationId = application.ApplicationId, Ukprn = application.ApplyData.ApplyDetails.UKPRN, ApplyLegalName = application.ApplyData.ApplyDetails.OrganisationName, ApplicationRoute = application.ApplyData.ApplyDetails.ProviderRouteName, SubmittedDate = application.ApplyData.ApplyDetails.ApplicationSubmittedOn, ApplicantEmailAddress = contact.Email, SequenceNumber = moderatorPage.SequenceNumber, SectionNumber = moderatorPage.SectionNumber, PageId = moderatorPage.PageId, NextPageId = moderatorPage.NextPageId, Caption = moderatorPage.Caption, Heading = moderatorPage.Heading, GuidanceInformation = moderatorPage.GuidanceInformation != null ? new List <string>(moderatorPage.GuidanceInformation) : new List <string>(), Questions = moderatorPage.Questions != null ? new List <Question>(moderatorPage.Questions) : new List <Question>(), Answers = moderatorPage.Answers != null ? new List <Answer>(moderatorPage.Answers) : new List <Answer>(), TabularData = GetTabularDataFromQuestionsAndAnswers(moderatorPage.Questions, moderatorPage.Answers), SupplementaryInformation = await _supplementaryInformationService.GetSupplementaryInformation(application.ApplicationId, moderatorPage.PageId), BlindAssessmentOutcome = await _moderationApiClient.GetBlindAssessmentOutcome(application.ApplicationId, moderatorPage.SequenceNumber, moderatorPage.SectionNumber, moderatorPage.PageId) }; await SetPageReviewOutcome(request, viewModel); return(viewModel); }
public async Task <IActionResult> ViewApplication(Guid applicationId) { var application = await _applyApiClient.GetApplication(applicationId); if (application is null) { return(RedirectToAction(nameof(OpenApplications))); } var vm = await CreateRoatpFinancialApplicationViewModel(application); var contact = await _applyApiClient.GetContactForApplication(application.ApplicationId); vm.ApplicantEmailAddress = contact?.Email; if (vm.ApplicationStatus == ApplicationStatus.Removed || vm.ApplicationStatus == ApplicationStatus.Withdrawn) { return(View("~/Views/Roatp/Apply/Financial/Application_Closed.cshtml", vm)); } else { var financialReviewDetails = await _applyApiClient.GetFinancialReviewDetails(applicationId); switch (financialReviewDetails?.Status) { case FinancialReviewStatus.New: case FinancialReviewStatus.InProgress: case null: await _applyApiClient.StartFinancialReview(application.ApplicationId, HttpContext.User.UserDisplayName()); return(View("~/Views/Roatp/Apply/Financial/Application.cshtml", vm)); case FinancialReviewStatus.ClarificationSent: var clarificationVm = ConvertFinancialApplicationToFinancialClarificationViewModel(vm, vm.ClarificationComments); return(View("~/Views/Roatp/Apply/Financial/Application_Clarification.cshtml", clarificationVm)); case FinancialReviewStatus.Pass: case FinancialReviewStatus.Fail: default: return(View("~/Views/Roatp/Apply/Financial/Application_ReadOnly.cshtml", vm)); } } }
public async Task <RoatpGatewayApplicationViewModel> GetOverviewViewModel(GetApplicationOverviewRequest request) { var application = await _applyApiClient.GetApplication(request.ApplicationId); if (application is null) { return(null); } var oversightDetails = await _applyApiClient.GetOversightDetails(request.ApplicationId); var contact = await _applyApiClient.GetContactDetails(request.ApplicationId); var viewmodel = new RoatpGatewayApplicationViewModel(application, oversightDetails) { ApplicationEmailAddress = contact?.Email, Sequences = GetCoreGatewayApplicationViewModel() }; var savedStatuses = await _applyApiClient.GetGatewayPageAnswers(request.ApplicationId); if (savedStatuses != null && !savedStatuses.Any()) { var providerRoute = application.ApplyData.ApplyDetails.ProviderRoute; await _sectionsNotRequiredService.SetupNotRequiredLinks(request.ApplicationId, request.UserName, viewmodel, providerRoute); } else { foreach (var currentStatus in savedStatuses ?? new List <GatewayPageAnswerSummary>()) { // Inject the statuses and comments into viewmodel viewmodel.Sequences.SelectMany(seq => seq.Sections).FirstOrDefault(sec => sec.PageId == currentStatus.PageId).Status = currentStatus?.Status; viewmodel.Sequences.SelectMany(seq => seq.Sections).FirstOrDefault(sec => sec.PageId == currentStatus.PageId).Comment = currentStatus?.Comments; } } var sections = viewmodel.Sequences.SelectMany(seq => seq.Sections); viewmodel.IsClarificationsSelectedAndAllFieldsSet = IsAskForClarificationActive(sections); viewmodel.ReadyToConfirm = IsReadyToConfirm(sections); return(viewmodel); }
public async Task <ClarificationOutcomeViewModel> GetClarificationOutcomeViewModel(GetClarificationOutcomeRequest request) { var application = await _applicationApiClient.GetApplication(request.ApplicationId); var contact = await _applicationApiClient.GetContactForApplication(request.ApplicationId); var outcomes = await _clarificationApiClient.GetAllClarificationPageReviewOutcomes(request.ApplicationId, request.UserId); if (application is null || contact is null || outcomes is null) { return(null); } var unsetOutcomesCount = outcomes.Count(x => x.Status != ClarificationPageReviewStatus.Pass && x.Status != ClarificationPageReviewStatus.Fail); if (unsetOutcomesCount > 0) { return(null); } return(new ClarificationOutcomeViewModel(application, outcomes)); }
public async Task <ModeratorOutcomeViewModel> GetInModerationOutcomeViewModel(GetModeratorOutcomeRequest request) { var application = await _applicationApiClient.GetApplication(request.ApplicationId); var contact = await _applicationApiClient.GetContactForApplication(request.ApplicationId); // TODO: Is this needed? var savedOutcomes = await _moderationApiClient.GetAllModeratorPageReviewOutcomes(request.ApplicationId, request.UserId); if (application is null || contact is null || savedOutcomes is null) { return(null); } // Not sure if this check is required. You're going to have Clarification ones in here soon var unsetOutcomesCount = savedOutcomes.Count(x => x.Status != ModeratorPageReviewStatus.Pass && x.Status != ModeratorPageReviewStatus.Fail); if (unsetOutcomesCount > 0) { return(null); } return(new ModeratorOutcomeViewModel(application, savedOutcomes)); }
public async Task <ModeratorApplicationViewModel> GetOverviewViewModel(GetModeratorOverviewRequest request) { var application = await _applicationApiClient.GetApplication(request.ApplicationId); var contact = await _applicationApiClient.GetContactForApplication(request.ApplicationId); var sequences = await _moderationApiClient.GetModeratorSequences(request.ApplicationId); if (application is null || contact is null || sequences is null) { return(null); } var viewmodel = new ModeratorApplicationViewModel(application, contact, sequences, request.UserId); var savedOutcomes = await _moderationApiClient.GetAllModeratorPageReviewOutcomes(request.ApplicationId, request.UserId); if (savedOutcomes is null || !savedOutcomes.Any()) { viewmodel.IsReadyForModeratorConfirmation = false; }
public async Task <IActionResult> PerformSnapshot(SnapshotViewModel vm) { if (_configuration["EnvironmentName"].EndsWith("PROD", StringComparison.InvariantCultureIgnoreCase)) { return(RedirectToAction("Index", "Dashboard")); } var application = await _applyApiClient.GetApplication(vm.ApplicationId ?? Guid.NewGuid()); if (vm.ApplicationId is null) { ModelState.AddModelError("ApplicationId", "Please enter Application Id"); } else if (application is null) { ModelState.AddModelError("ApplicationId", "Application not found"); } if (ModelState.IsValid) { var snapshotResponse = await _qnaApiClient.SnapshotApplication(application.ApplicationId); var allSnapshotSequences = await _qnaApiClient.GetAllApplicationSequences(snapshotResponse.ApplicationId); var allSnapshotSections = await _qnaApiClient.GetAllApplicationSections(snapshotResponse.ApplicationId); var applySequences = application.ApplyData.Sequences; // must update all ids! foreach (var sequence in applySequences) { var snapshotSequence = allSnapshotSequences.FirstOrDefault(seq => seq.SequenceNo == sequence.SequenceNo); if (snapshotSequence != null) { sequence.SequenceId = snapshotSequence.Id; foreach (var section in sequence.Sections) { var snapshotSection = allSnapshotSections.FirstOrDefault(sec => sec.SequenceNo == sequence.SequenceNo && sec.SectionNo == section.SectionNo); if (snapshotSection != null) { section.SectionId = snapshotSection.Id; } } } } var applySnapshotResponse = await _applyApiClient.SnapshotApplication(application.ApplicationId, snapshotResponse.ApplicationId, applySequences); if (applySnapshotResponse != Guid.Empty) { vm.SnapshotApplicationId = applySnapshotResponse; vm.SnapshotSuccessful = true; } else { vm.SnapshotSuccessful = false; } } return(View("~/Views/Roatp/Apply/Snapshot/Index.cshtml", vm)); }