public async Task AboutToConfirmOutcome_selection_No()
        {
            var applicationId      = Guid.NewGuid();
            var expectedActionName = "ConfirmOutcome";
            var viewModel          = new RoatpGatewayConfirmOutcomeViewModel
            {
                ApplicationId         = applicationId,
                GatewayReviewStatus   = GatewayReviewStatus.Pass,
                GatewayReviewComment  = "some comment",
                ConfirmGatewayOutcome = "No"
            };

            var result = await _controller.AboutToConfirmOutcome(viewModel);

            var redirectToActionResult = result as RedirectToActionResult;

            Assert.AreSame(expectedActionName, redirectToActionResult.ActionName);
            ApplyApiClient.Verify(x => x.UpdateGatewayReviewStatusAndComment(applicationId, viewModel.GatewayReviewStatus, viewModel.GatewayReviewComment, viewModel.GatewayReviewExternalComment, viewModel.SubcontractingLimit, UserId, Username), Times.Never);
        }
        public async Task AboutToConfirmOutcome_selection_Yes()
        {
            var applicationId = Guid.NewGuid();
            var viewModel     = new RoatpGatewayConfirmOutcomeViewModel
            {
                ApplicationId         = applicationId,
                GatewayReviewStatus   = GatewayReviewStatus.Pass,
                GatewayReviewComment  = "some comment",
                ConfirmGatewayOutcome = "Yes"
            };

            var result = await _controller.AboutToConfirmOutcome(viewModel);

            var viewResult      = result as ViewResult;
            var viewResultModel = viewResult.Model as RoatpGatewayOutcomeViewModel;

            Assert.AreSame(viewModel.GatewayReviewStatus, viewResultModel.GatewayReviewStatus);
            ApplyApiClient.Verify(x => x.UpdateGatewayReviewStatusAndComment(applicationId, viewModel.GatewayReviewStatus, viewModel.GatewayReviewComment, string.Empty, viewModel.SubcontractingLimit, UserId, Username), Times.Once);
        }
        public async Task AboutToConfirmOutcome_no_selection()
        {
            var applicationId = Guid.NewGuid();
            var viewModel     = new RoatpGatewayConfirmOutcomeViewModel
            {
                ApplicationId        = applicationId,
                GatewayReviewStatus  = GatewayReviewStatus.Pass,
                GatewayReviewComment = "some comment"
            };

            _controller.ModelState.AddModelError("ConfirmGatewayOutcome", "Select if you are sure you want to pass this application");

            var result = await _controller.AboutToConfirmOutcome(viewModel);

            var viewResult      = result as ViewResult;
            var resultViewModel = viewResult.Model as RoatpGatewayConfirmOutcomeViewModel;

            Assert.AreSame(HtmlAndCssElements.CssFormGroupErrorClass, resultViewModel.CssFormGroupError);
            ApplyApiClient.Verify(x => x.UpdateGatewayReviewStatusAndComment(applicationId, viewModel.GatewayReviewStatus, viewModel.GatewayReviewComment, viewModel.GatewayReviewExternalComment, viewModel.SubcontractingLimit, UserId, Username), Times.Never);
        }
Пример #4
0
        public async Task <IActionResult> AboutToConfirmOutcome(RoatpGatewayConfirmOutcomeViewModel viewModel)
        {
            if (viewModel.ApplicationStatus == ApplicationStatus.GatewayAssessed)
            {
                return(RedirectToAction(nameof(NewApplications)));
            }

            if (ModelState.IsValid)
            {
                if (viewModel.ConfirmGatewayOutcome.Equals(HtmlAndCssElements.RadioButtonValueYes, StringComparison.InvariantCultureIgnoreCase))
                {
                    var username = HttpContext.User.UserDisplayName();
                    var userId   = HttpContext.User.UserId();
                    await _applyApiClient.UpdateGatewayReviewStatusAndComment(viewModel.ApplicationId, viewModel.GatewayReviewStatus, viewModel.GatewayReviewComment, String.Empty, userId, username);

                    var vm = new RoatpGatewayOutcomeViewModel {
                        GatewayReviewStatus = viewModel.GatewayReviewStatus
                    };
                    return(View("~/Views/Gateway/GatewayOutcomeConfirmation.cshtml", vm));
                }
                else
                {
                    return(RedirectToAction(nameof(ConfirmOutcome), new
                    {
                        applicationId = viewModel.ApplicationId,
                        gatewayReviewStatus = viewModel.GatewayReviewStatus,
                        gatewayReviewComment = viewModel.GatewayReviewComment,
                        gatewayReviewExternalComments = viewModel.GatewayReviewExternalComment
                    }));
                }
            }
            else
            {
                viewModel.CssFormGroupError = HtmlAndCssElements.CssFormGroupErrorClass;
                return(View("~/Views/Gateway/ConfirmOutcomeApproved.cshtml", viewModel));
            }
        }
Пример #5
0
        public async Task <IActionResult> EvaluateConfirmOutcome(RoatpGatewayApplicationViewModel viewModel)
        {
            var application = await _applyApiClient.GetApplication(viewModel.ApplicationId);

            if (application is null || application.ApplicationStatus == ApplicationStatus.GatewayAssessed)
            {
                return(RedirectToAction(nameof(NewApplications)));
            }

            var validationResponse = await _validator.Validate(viewModel);

            if (validationResponse.Errors != null && validationResponse.Errors.Any())
            {
                var username         = HttpContext.User.UserDisplayName();
                var viewModelOnError = await _orchestrator.GetConfirmOverviewViewModel(new GetApplicationOverviewRequest(viewModel.ApplicationId, username));

                if (viewModelOnError != null)
                {
                    _orchestrator.ProcessViewModelOnError(viewModelOnError, viewModel, validationResponse);
                    return(View("~/Views/Gateway/ConfirmOutcome.cshtml", viewModelOnError));
                }
                else
                {
                    return(RedirectToAction(nameof(ViewApplication), new { applicationId = viewModel.ApplicationId }));
                }
            }

            var viewName = "~/Views/Gateway/ConfirmOutcomeAskClarification.cshtml";


            var confirmViewModel = new RoatpGatewayOutcomeViewModel {
                ApplicationId = viewModel.ApplicationId, GatewayReviewStatus = viewModel.GatewayReviewStatus
            };

            switch (viewModel.GatewayReviewStatus)
            {
            case GatewayReviewStatus.ClarificationSent:
            {
                confirmViewModel.GatewayReviewComment = viewModel.OptionAskClarificationText;
                break;
            }

            case GatewayReviewStatus.Fail:
            {
                confirmViewModel = new RoatpGatewayFailOutcomeViewModel
                {
                    ApplicationId                = viewModel.ApplicationId,
                    GatewayReviewStatus          = viewModel.GatewayReviewStatus,
                    GatewayReviewComment         = viewModel.OptionFailedText,
                    GatewayReviewExternalComment = viewModel.OptionFailedExternalText
                };
                viewName = "~/Views/Gateway/ConfirmOutcomeFailed.cshtml";
                break;
            }

            case GatewayReviewStatus.Pass:
            {
                confirmViewModel = new RoatpGatewayConfirmOutcomeViewModel
                {
                    ApplicationId                = viewModel.ApplicationId,
                    GatewayReviewStatus          = viewModel.GatewayReviewStatus,
                    GatewayReviewComment         = viewModel.OptionApprovedText,
                    GatewayReviewExternalComment = string.Empty
                };
                viewName = "~/Views/Gateway/ConfirmOutcomeApproved.cshtml";
                break;
            }

            case GatewayReviewStatus.Reject:
            {
                var contact = await _applyApiClient.GetContactDetails(viewModel.ApplicationId);

                confirmViewModel = new RoatpGatewayRejectOutcomeViewModel
                {
                    ApplicationId                = viewModel.ApplicationId,
                    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,
                    GatewayReviewStatus          = viewModel.GatewayReviewStatus,
                    GatewayReviewComment         = viewModel.OptionRejectedText,
                    GatewayReviewExternalComment = viewModel.OptionExternalRejectedText
                };
                viewName = "~/Views/Gateway/ConfirmOutcomeRejected.cshtml";
                break;
            }
            }

            return(View(viewName, confirmViewModel));
        }