Пример #1
0
        public async Task <OutcomeDetailsViewModel> GetOversightDetailsViewModel(Guid applicationId, Guid?outcomeKey)
        {
            var applicationDetailsTask = _applyApiClient.GetApplicationDetails(applicationId);
            var oversightReviewTask    = _applyApiClient.GetOversightReview(applicationId);
            await Task.WhenAll(applicationDetailsTask, oversightReviewTask);

            var applicationDetails = _applyApiClient.GetApplicationDetails(applicationId).Result;
            var oversightReview    = _applyApiClient.GetOversightReview(applicationId).Result;
            var onRegister         = false;

            if (applicationDetails?.Ukprn != null)
            {
                var registerStatus = await _registerApiClient.GetOrganisationRegisterStatus(new GetOrganisationRegisterStatusRequest { UKPRN = applicationDetails.Ukprn });

                onRegister = registerStatus.UkprnOnRegister;
            }


            var viewModel = new OutcomeDetailsViewModel
            {
                IsNew = oversightReview == null,
                ApplicationSummary     = CreateApplicationSummaryViewModel(applicationDetails),
                GatewayOutcome         = CreateGatewayOutcomeViewModel(applicationDetails, oversightReview),
                FinancialHealthOutcome = CreateFinancialHealthOutcomeViewModel(applicationDetails),
                ModerationOutcome      = CreateModerationOutcomeViewModel(applicationDetails, oversightReview),
                InProgressDetails      = CreateInProgressDetailsViewModel(oversightReview),
                OverallOutcome         = CreateOverallOutcomeViewModel(oversightReview),
                ShowInProgressDetails  = oversightReview?.InProgressDate != null,
                OversightStatus        = oversightReview?.Status ?? OversightReviewStatus.None,
                ApproveGateway         = GetStringValueForApprovalStatusBoolean(oversightReview?.GatewayApproved),
                ApproveModeration      = GetStringValueForApprovalStatusBoolean(oversightReview?.ModerationApproved),
                IsGatewayRemoved       = applicationDetails.ApplicationStatus == ApplicationStatus.Removed,
                IsGatewayFail          = applicationDetails.GatewayReviewStatus == GatewayReviewStatus.Fail,
                HasFinalOutcome        = oversightReview != null && oversightReview.Status != OversightReviewStatus.None && oversightReview.Status != OversightReviewStatus.InProgress,
                OnRegister             = onRegister
            };

            if (oversightReview == null || oversightReview.Status == OversightReviewStatus.InProgress)
            {
                var cachedItem = await _cacheStorageService.RetrieveFromCache <OutcomePostRequest>(outcomeKey.ToString());

                if (cachedItem == null)
                {
                    return(viewModel);
                }

                viewModel.OversightStatus                 = cachedItem.OversightStatus;
                viewModel.ApproveGateway                  = cachedItem.ApproveGateway;
                viewModel.ApproveModeration               = cachedItem.ApproveModeration;
                viewModel.SuccessfulText                  = cachedItem.SuccessfulText;
                viewModel.SuccessfulAlreadyActiveText     = cachedItem.SuccessfulAlreadyActiveText;
                viewModel.SuccessfulFitnessForFundingText = cachedItem.SuccessfulFitnessForFundingText;
                viewModel.UnsuccessfulText                = cachedItem.UnsuccessfulText;
                viewModel.UnsuccessfulExternalText        = cachedItem.UnsuccessfulExternalText;
                viewModel.InProgressInternalText          = cachedItem.InProgressInternalText;
                viewModel.InProgressExternalText          = cachedItem.InProgressExternalText;
            }

            return(viewModel);
        }
Пример #2
0
        public async Task GetOutcome_returns_view_with_expected_viewModel()
        {
            var viewModel = new OutcomeDetailsViewModel {
                ApplicationSummary = new ApplicationSummaryViewModel {
                    ApplicationId = _applicationDetailsApplicationId
                }
            };

            _oversightOrchestrator.Setup(x => x.GetOversightDetailsViewModel(_applicationDetailsApplicationId, null)).ReturnsAsync(viewModel);

            var request = new OutcomeRequest {
                ApplicationId = _applicationDetailsApplicationId
            };
            var result = await _controller.Outcome(request) as ViewResult;

            var actualViewModel = result?.Model as OutcomeDetailsViewModel;

            Assert.That(result, Is.Not.Null);
            Assert.That(actualViewModel, Is.Not.Null);
            Assert.That(actualViewModel, Is.SameAs(viewModel));
            Assert.AreEqual(_applicationDetailsApplicationId, actualViewModel.ApplicationSummary.ApplicationId);
        }
Пример #3
0
        public async Task Post_Outcome_Gateway_Fail_Redirects_To_Confirmed_Page()
        {
            var viewModel = new OutcomeDetailsViewModel {
                ApplicationSummary = new ApplicationSummaryViewModel {
                    ApplicationId = _applicationDetailsApplicationId
                }
            };

            _oversightOrchestrator.Setup(x => x.GetOversightDetailsViewModel(_applicationDetailsApplicationId, null)).ReturnsAsync(viewModel);

            var command = new OutcomePostRequest
            {
                ApplicationId     = _applicationDetailsApplicationId,
                OversightStatus   = OversightReviewStatus.Unsuccessful,
                ApproveGateway    = GatewayReviewStatus.Fail,
                ApproveModeration = ModerationReviewStatus.Fail,
                UnsuccessfulText  = "test",
                IsGatewayFail     = true
            };

            var result = await _controller.Outcome(command) as RedirectToActionResult;

            Assert.AreEqual("Confirmed", result.ActionName);
        }
Пример #4
0
        public async Task Post_Outcome_Gateway_Removed_Records_Gateway_Removed_Outcome()
        {
            var viewModel = new OutcomeDetailsViewModel {
                ApplicationSummary = new ApplicationSummaryViewModel {
                    ApplicationId = _applicationDetailsApplicationId
                }
            };

            _oversightOrchestrator.Setup(x => x.GetOversightDetailsViewModel(_applicationDetailsApplicationId, null)).ReturnsAsync(viewModel);

            var command = new OutcomePostRequest
            {
                ApplicationId     = _applicationDetailsApplicationId,
                OversightStatus   = OversightReviewStatus.Unsuccessful,
                ApproveGateway    = GatewayReviewStatus.Fail,
                ApproveModeration = ModerationReviewStatus.Fail,
                UnsuccessfulText  = "test",
                IsGatewayRemoved  = true
            };

            await _controller.Outcome(command);

            _outcomeOrchestrator.Verify(x => x.RecordGatewayRemovedOutcome(It.Is <Guid>(id => id == command.ApplicationId), It.IsAny <string>(), It.IsAny <string>()));
        }