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)); } } }