private RoatpGatewayApplicationViewModel ProcessViewModelOnError(Guid applicationId, string gatewayReviewStatus, string field, string errorMessage)
        {
            var viewModelOnError = new RoatpGatewayApplicationViewModel
            {
                ApplicationId       = applicationId,
                GatewayReviewStatus = gatewayReviewStatus
            };

            var viewModel = new RoatpGatewayApplicationViewModel
            {
                ApplicationId       = applicationId,
                GatewayReviewStatus = gatewayReviewStatus
            };

            var validationResponse = new ValidationResponse
            {
                Errors = new List <ValidationErrorDetail>
                {
                    new ValidationErrorDetail
                    {
                        Field        = field,
                        ErrorMessage = errorMessage
                    }
                }
            };

            _orchestrator.ProcessViewModelOnError(viewModelOnError, viewModel, validationResponse);

            return(viewModelOnError);
        }
コード例 #2
0
        public async Task <IActionResult> EvaluateGateway(RoatpGatewayApplicationViewModel viewModel, bool?isGatewayApproved)
        {
            var application = await _applyApiClient.GetApplication(viewModel.ApplicationId);

            if (application is null)
            {
                return(RedirectToAction(nameof(NewApplications)));
            }

            if (!isGatewayApproved.HasValue)
            {
                ModelState.AddModelError("IsGatewayApproved", "Please evaluate Gateway");
            }

            if (ModelState.IsValid)
            {
                var username = HttpContext.User.UserDisplayName();
                var userId   = HttpContext.User.UserId();
                await _applyApiClient.EvaluateGateway(viewModel.ApplicationId, isGatewayApproved.Value, userId, username);

                return(RedirectToAction(nameof(Evaluated), new { viewModel.ApplicationId }));
            }
            else
            {
                var username     = HttpContext.User.UserDisplayName();
                var newViewModel = await _orchestrator.GetOverviewViewModel(new GetApplicationOverviewRequest(application.ApplicationId, username));

                return(View("~/Views/Gateway/Application.cshtml", newViewModel));
            }
        }
        public async Task ViewApplication_when_submitted_for_review_shows_expected_view(string gatewayReviewStatus)
        {
            var applicationId = Guid.NewGuid();

            var application = new Apply
            {
                ApplicationId       = applicationId,
                ApplicationStatus   = ApplicationStatus.Submitted,
                GatewayReviewStatus = gatewayReviewStatus,
                ApplyData           = new ApplyData {
                    ApplyDetails = new ApplyDetails()
                }
            };

            var oversightDetails = new ApplicationOversightDetails {
                OversightStatus = OversightReviewStatus.None
            };

            var viewmodel = new RoatpGatewayApplicationViewModel(application, oversightDetails);

            _orchestrator.Setup(x => x.GetOverviewViewModel(It.IsAny <GetApplicationOverviewRequest>())).ReturnsAsync(viewmodel);

            var result = await _controller.ViewApplication(applicationId);

            var viewResult = result as ViewResult;

            Assert.IsTrue(viewResult.ViewName.EndsWith("Application.cshtml"));
        }
コード例 #4
0
        public async Task <IActionResult> EvaluateConfirmOutcome(RoatpGatewayApplicationViewModel viewModel)
        {
            var application = await _applyApiClient.GetApplication(viewModel.ApplicationId);

            if (application?.ApplyData?.ApplyDetails is null || application.ApplicationStatus == ApplicationStatus.GatewayAssessed)
            {
                return(RedirectToAction(nameof(NewApplications)));
            }
        public void Test_cases_for_Pass_status_and_subcontracting_limit_check_message_as_expected(string applicationRoute, int?subcontractingLimit, bool hasErrorMessage)
        {
            _viewModel = new RoatpGatewayApplicationViewModel
            {
                GatewayReviewStatus = GatewayReviewStatus.Pass,
                OptionApprovedText  = "valid",
                SubcontractingLimit = subcontractingLimit,
                ApplicationRoute    = applicationRoute
            };

            var result = _validator.Validate(_viewModel).Result;

            Assert.AreEqual(hasErrorMessage, result.Errors.Any());
        }
コード例 #6
0
        public async Task SetupNotRequiredLinks(Guid applicationId, string userName, RoatpGatewayApplicationViewModel viewModel, int providerRoute)
        {
            await SetupNotRequiredLinkForTradingName(applicationId, userName, viewModel);

            await SetupNotRequiredLinkForWebsiteAddress(applicationId, userName, viewModel);

            await SetupNotRequiredLinkForOfficeForStudents(applicationId, userName, viewModel, providerRoute);

            await SetupNotRequiredLinkForInitialTeacherTraining(applicationId, userName, viewModel, providerRoute);

            await SetupNotRequireLinkForOfsted(applicationId, userName, viewModel, providerRoute);

            await SetupNotRequiredLinkForSubcontractorDeclaration(applicationId, userName, viewModel, providerRoute);
        }
        public async Task ConfirmOutcome_evaluation_result_is_on_error()
        {
            var applicationId = Guid.NewGuid();

            ApplyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(new Apply {
                ApplicationId = applicationId, ApplyData = new ApplyData {
                    ApplyDetails = new ApplyDetails {
                    }
                }
            });

            var viewModel = new RoatpGatewayApplicationViewModel
            {
                ApplicationId       = applicationId,
                GatewayReviewStatus = GatewayReviewStatus.InProgress,
                ErrorMessages       = new List <ValidationErrorDetail>()
            };

            _validator.Setup(v => v.Validate(viewModel))
            .ReturnsAsync(new ValidationResponse
            {
                Errors = new List <ValidationErrorDetail>
                {
                    new ValidationErrorDetail {
                        Field = "GatewayReviewStatus", ErrorMessage = "Select what you want to do"
                    }
                }
            });

            var expectedViewModelWithErrors = new RoatpGatewayApplicationViewModel
            {
                ApplicationId       = applicationId,
                GatewayReviewStatus = GatewayReviewStatus.New,
                ErrorMessages       = new List <ValidationErrorDetail>
                {
                    new ValidationErrorDetail {
                        Field = "GatewayReviewStatus", ErrorMessage = "Select what you want to do"
                    }
                }
            };

            _orchestrator.Setup(x => x.GetConfirmOverviewViewModel(It.Is <GetApplicationOverviewRequest>(y => y.ApplicationId == applicationId && y.UserName == Username))).ReturnsAsync(expectedViewModelWithErrors);

            var result = await _controller.EvaluateConfirmOutcome(viewModel);

            var viewResult = result as ViewResult;

            Assert.AreSame(expectedViewModelWithErrors, viewResult.Model);
        }
        public void Test_cases_for_no_status_and_no_fail_text_to_check_messages_as_expected(string gatewayReviewStatus, string clarificationMessage, string declinedMessage, string approvedMessage, string declinedExternalMessage, bool hasErrorMessage)
        {
            _viewModel = new RoatpGatewayApplicationViewModel
            {
                GatewayReviewStatus        = gatewayReviewStatus,
                OptionAskClarificationText = clarificationMessage,
                OptionFailedText           = declinedMessage,
                OptionApprovedText         = approvedMessage,
                OptionRejectedText         = declinedMessage,
                OptionFailedExternalText   = declinedExternalMessage,
                OptionExternalRejectedText = declinedExternalMessage
            };

            var result = _validator.Validate(_viewModel).Result;

            Assert.AreEqual(hasErrorMessage, result.Errors.Any());
        }
        public async Task ConfirmOutcome_model_is_returned()
        {
            var applicationId     = Guid.NewGuid();
            var expectedViewModel = new RoatpGatewayApplicationViewModel {
                ReadyToConfirm = true
            };

            ApplyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(new Apply {
                ApplicationId = applicationId
            });
            _orchestrator.Setup(x => x.GetConfirmOverviewViewModel(It.Is <GetApplicationOverviewRequest>(y => y.ApplicationId == applicationId && y.UserName == Username))).ReturnsAsync(expectedViewModel);

            var result = await _controller.ConfirmOutcome(applicationId, GatewayReviewStatus.Pass, null, null, 0);

            var viewResult = result as ViewResult;

            Assert.AreSame(expectedViewModel, viewResult.Model);
        }
コード例 #10
0
        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 ConfirmOutcome_evaluation_fail_result()
        {
            var applicationId = Guid.NewGuid();

            var viewModel = new RoatpGatewayApplicationViewModel
            {
                ApplicationId       = applicationId,
                GatewayReviewStatus = GatewayReviewStatus.Fail,
                OptionApprovedText  = "Some approved text",
                ErrorMessages       = new List <ValidationErrorDetail>()
            };

            _validator.Setup(v => v.Validate(viewModel)).ReturnsAsync(new ValidationResponse {
                Errors = new List <ValidationErrorDetail>()
            });

            await _controller.EvaluateConfirmOutcome(viewModel);

            _orchestrator.Verify(x => x.GetConfirmOverviewViewModel(new GetApplicationOverviewRequest(viewModel.ApplicationId, Username)), Times.Never);
        }
コード例 #12
0
        public async Task <RoatpGatewayApplicationViewModel> GetConfirmOverviewViewModel(GetApplicationOverviewRequest request)
        {
            var application = await _applyApiClient.GetApplication(request.ApplicationId);

            if (application is null)
            {
                return(null);
            }

            var oversightDetails = await _applyApiClient.GetOversightDetails(request.ApplicationId);

            var viewmodel = new RoatpGatewayApplicationViewModel(application, oversightDetails)
            {
                Sequences = GetCoreGatewayApplicationViewModel()
            };

            var savedStatuses = await _applyApiClient.GetGatewayPageAnswers(request.ApplicationId);

            if (savedStatuses != null && !savedStatuses.Any())
            {
                viewmodel.ReadyToConfirm = false;
                return(viewmodel);
            }
            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 = sections.Any(x => x.Status == SectionReviewStatus.Clarification);
            viewmodel.ReadyToConfirm = IsReadyToConfirm(sections);

            return(viewmodel);
        }
        public void Test_cases_where_external_comment_is_too_long(string gatewayReviewStatus, int wordCount, bool hasErrorMessage)
        {
            var words = string.Empty;

            for (var i = 0; i < wordCount; i++)
            {
                words = $"{words}{i} ";
            }

            _viewModel = new RoatpGatewayApplicationViewModel();
            _viewModel.GatewayReviewStatus        = gatewayReviewStatus;
            _viewModel.OptionAskClarificationText = "valid";
            _viewModel.OptionFailedText           = "valid";
            _viewModel.OptionApprovedText         = "valid";
            _viewModel.OptionRejectedText         = "valid";
            _viewModel.OptionFailedExternalText   = words;
            _viewModel.OptionExternalRejectedText = words;

            var result = _validator.Validate(_viewModel).Result;

            Assert.AreEqual(hasErrorMessage, result.Errors.Any());
        }
        public async Task ViewApplication_when_Application_Removed_shows_expected_view()
        {
            var applicationId = Guid.NewGuid();

            var application = new Apply
            {
                ApplicationId       = applicationId,
                ApplicationStatus   = ApplicationStatus.Removed,
                GatewayReviewStatus = GatewayReviewStatus.InProgress,
                ApplyData           = new ApplyData {
                    ApplyDetails = new ApplyDetails()
                }
            };

            var viewmodel = new RoatpGatewayApplicationViewModel(application, new ApplicationOversightDetails());

            _orchestrator.Setup(x => x.GetOverviewViewModel(It.IsAny <GetApplicationOverviewRequest>())).ReturnsAsync(viewmodel);

            var result = await _controller.ViewApplication(applicationId);

            var viewResult = result as ViewResult;

            Assert.IsTrue(viewResult.ViewName.EndsWith("Application_Closed.cshtml"));
        }
コード例 #15
0
        private async Task SetupNotRequiredLinkForWebsiteAddress(Guid applicationId, string userName, RoatpGatewayApplicationViewModel viewModel)
        {
            var applyWebsite = await _applyApiClient.GetOrganisationWebsiteAddress(applicationId);

            if (string.IsNullOrEmpty(applyWebsite))
            {
                var page = viewModel?.Sequences?.SelectMany(seq => seq.Sections)
                           .Where(sec => sec.PageId == GatewayPageIds.WebsiteAddress)?.FirstOrDefault();

                if (page != null)
                {
                    page.Status = SectionReviewStatus.NotRequired;
                }
                _logger.LogInformation($"GetApplicationOverviewHandler-SubmitGatewayPageAnswer - ApplicationId '{applicationId}' - PageId '{GatewayPageIds.WebsiteAddress}' - Status '{SectionReviewStatus.NotRequired}' - UserName '{userName}' - PageData = 'null'");
                await _applyApiClient.SubmitGatewayPageAnswer(applicationId, GatewayPageIds.WebsiteAddress, SectionReviewStatus.NotRequired, null, null, null, null);
            }
        }
コード例 #16
0
        public void Before_each_test()
        {
            _applicationId = Guid.NewGuid();

            _apiClient           = new Mock <IRoatpApplicationApiClient>();
            _accreditationClient = new Mock <IRoatpExperienceAndAccreditationApiClient>();
            _logger  = new Mock <ILogger <GatewaySectionsNotRequiredService> >();
            _service = new GatewaySectionsNotRequiredService(_apiClient.Object, _accreditationClient.Object, _logger.Object);

            var application = new Apply();

            _viewModel = new RoatpGatewayApplicationViewModel(application, new ApplicationOversightDetails {
                OversightStatus = OversightReviewStatus.None
            })
            {
                Sequences = new List <GatewaySequence>
                {
                    new GatewaySequence
                    {
                        SequenceNumber = GatewaySequences.OrganisationChecks,
                        Sections       = new List <GatewaySection>
                        {
                            new GatewaySection
                            {
                                PageId = GatewayPageIds.TradingName,
                                Status = SectionReviewStatus.New
                            },
                            new GatewaySection
                            {
                                PageId = GatewayPageIds.WebsiteAddress,
                                Status = SectionReviewStatus.New
                            },
                            new GatewaySection
                            {
                                PageId = GatewayPageIds.OfficeForStudents,
                                Status = SectionReviewStatus.New
                            },
                            new GatewaySection
                            {
                                PageId = GatewayPageIds.InitialTeacherTraining,
                                Status = SectionReviewStatus.New
                            },
                            new GatewaySection
                            {
                                PageId = GatewayPageIds.Ofsted,
                                Status = SectionReviewStatus.New
                            },
                            new GatewaySection
                            {
                                PageId = GatewayPageIds.SubcontractorDeclaration,
                                Status = SectionReviewStatus.New
                            }
                        }
                    },
                    new GatewaySequence
                    {
                        SequenceNumber = GatewaySequences.PeopleInControlCriminalComplianceChecks,
                        Sections       = new List <GatewaySection>
                        {
                            new GatewaySection
                            {
                                PageId = GatewayPageIds.CriminalComplianceWhosInControlChecks.Bankrupt,
                                Status = SectionReviewStatus.New
                            },
                            new GatewaySection
                            {
                                PageId = GatewayPageIds.CriminalComplianceWhosInControlChecks.ContractTerminated,
                                Status = SectionReviewStatus.New
                            },
                            new GatewaySection
                            {
                                PageId = GatewayPageIds.CriminalComplianceWhosInControlChecks.FraudIrregularities,
                                Status = SectionReviewStatus.New
                            }
                        }
                    }
                }
            };
            var providerDetails = new ProviderDetails
            {
                VerificationDetails = new List <VerificationDetails>
                {
                    new VerificationDetails
                    {
                        VerificationAuthority = VerificationAuthorities.CompaniesHouseAuthority
                    }
                }
            };

            _apiClient.Setup(x => x.GetUkrlpDetails(_applicationId)).ReturnsAsync(providerDetails);
        }
コード例 #17
0
        private async Task SetupNotRequiredLinkForTradingName(Guid applicationId, string userName, RoatpGatewayApplicationViewModel viewModel)
        {
            var tradingName = await _applyApiClient.GetTradingName(applicationId);

            if (string.IsNullOrEmpty(tradingName))
            {
                var page = GetSectionByPageId(viewModel, GatewayPageIds.TradingName);

                if (page != null)
                {
                    page.Status = SectionReviewStatus.NotRequired;
                }

                _logger.LogInformation($"GetApplicationOverviewHandler-SubmitGatewayPageAnswer - ApplicationId '{applicationId}' - PageId '{GatewayPageIds.TradingName}' - Status '{SectionReviewStatus.NotRequired}' - UserName '{userName}' - PageData = 'null'");
                await _applyApiClient.SubmitGatewayPageAnswer(applicationId, GatewayPageIds.TradingName, SectionReviewStatus.NotRequired, null, null, null, null);
            }
        }
コード例 #18
0
 private GatewaySection GetSectionByPageId(RoatpGatewayApplicationViewModel viewModel, string gatewayPageId)
 {
     return(viewModel?.Sequences?.SelectMany(seq => seq.Sections)
            .Where(sec => sec.PageId == gatewayPageId)?.FirstOrDefault());
 }
コード例 #19
0
        private async Task SetupNotRequireLinkForOfsted(Guid applicationId, string userName, RoatpGatewayApplicationViewModel viewModel, int providerRoute)
        {
            var ofstedStatus = SectionReviewStatus.NotRequired;

            if (providerRoute == (int)ProviderTypes.Main || providerRoute == (int)ProviderTypes.Employer)
            {
                var initialTeacherTraining = await _accreditationClient.GetInitialTeacherTraining(applicationId);

                if (initialTeacherTraining != null && (initialTeacherTraining.DoesOrganisationOfferInitialTeacherTraining is false || initialTeacherTraining.IsPostGradOnlyApprenticeship is false))
                {
                    ofstedStatus = string.Empty;
                }
            }

            if (ofstedStatus.Equals(SectionReviewStatus.NotRequired))
            {
                var page = GetSectionByPageId(viewModel, GatewayPageIds.Ofsted);

                if (page != null)
                {
                    page.Status = SectionReviewStatus.NotRequired;
                }

                _logger.LogInformation($"GetApplicationOverviewHandler-SubmitGatewayPageAnswer - ApplicationId '{applicationId}' - PageId '{GatewayPageIds.Ofsted}' - Status '{SectionReviewStatus.NotRequired}' - UserName '{userName}' - PageData = 'null'");
                await _applyApiClient.SubmitGatewayPageAnswer(applicationId, GatewayPageIds.Ofsted, SectionReviewStatus.NotRequired, null, null, null, null);
            }
        }
        public async Task <ValidationResponse> Validate(RoatpGatewayApplicationViewModel viewModel)
        {
            var validationResponse = new ValidationResponse
            {
                Errors = new List <ValidationErrorDetail>()
            };

            if (string.IsNullOrEmpty(viewModel.GatewayReviewStatus) ||
                !string.IsNullOrEmpty(viewModel.GatewayReviewStatus) &&
                !viewModel.GatewayReviewStatus.Equals(GatewayReviewStatus.ClarificationSent) &&
                !viewModel.GatewayReviewStatus.Equals(GatewayReviewStatus.Fail) &&
                !viewModel.GatewayReviewStatus.Equals(GatewayReviewStatus.Pass) &&
                !viewModel.GatewayReviewStatus.Equals(GatewayReviewStatus.Reject))
            {
                validationResponse.Errors.Add(new ValidationErrorDetail("GatewayReviewStatus", NoSelectionErrorMessage));
            }

            if (validationResponse.Errors.Any())
            {
                return(await Task.FromResult(validationResponse));
            }


            switch (viewModel.GatewayReviewStatus)
            {
            case GatewayReviewStatus.ClarificationSent:
            {
                if (string.IsNullOrEmpty(viewModel.OptionAskClarificationText))
                {
                    validationResponse.Errors.Add(new ValidationErrorDetail("OptionAskClarificationText", ErrorEnterClarificationComments));
                }
                else
                {
                    var wordCount = viewModel.OptionAskClarificationText.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Length;
                    if (wordCount > 150)
                    {
                        validationResponse.Errors.Add(new ValidationErrorDetail("OptionAskClarificationText", TooManyWords150));
                    }
                }


                break;
            }

            case GatewayReviewStatus.Fail:
            {
                if (string.IsNullOrEmpty(viewModel.OptionFailedText))
                {
                    validationResponse.Errors.Add(new ValidationErrorDetail("OptionFailedText", ErrorEnterInternalComments));
                }
                else
                {
                    var wordCount = viewModel.OptionFailedText.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Length;
                    if (wordCount > 150)
                    {
                        validationResponse.Errors.Add(new ValidationErrorDetail("OptionFailedText", TooManyWords150));
                    }
                }

                if (string.IsNullOrEmpty(viewModel.OptionFailedExternalText))
                {
                    validationResponse.Errors.Add(new ValidationErrorDetail("OptionFailedExternalText", ErrorEnterExternalComments));
                }
                else
                {
                    var wordCount = viewModel.OptionFailedExternalText.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Length;
                    if (wordCount > 500)
                    {
                        validationResponse.Errors.Add(new ValidationErrorDetail("OptionFailedExternalText", TooManyWords500));
                    }
                }
                break;
            }

            case GatewayReviewStatus.Reject:
            {
                if (string.IsNullOrEmpty(viewModel.OptionRejectedText))
                {
                    validationResponse.Errors.Add(new ValidationErrorDetail("OptionRejectedText", ErrorEnterInternalComments));
                }
                else
                {
                    var wordCount = viewModel.OptionRejectedText.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Length;
                    if (wordCount > 150)
                    {
                        validationResponse.Errors.Add(new ValidationErrorDetail("OptionRejectedText", TooManyWords150));
                    }
                }

                if (string.IsNullOrEmpty(viewModel.OptionExternalRejectedText))
                {
                    validationResponse.Errors.Add(new ValidationErrorDetail("OptionExternalRejectedText", ErrorEnterExternalComments));
                }
                else
                {
                    var wordCount = viewModel.OptionExternalRejectedText.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Length;
                    if (wordCount > 500)
                    {
                        validationResponse.Errors.Add(new ValidationErrorDetail("OptionExternalRejectedText", TooManyWords500));
                    }
                }
                break;
            }

            case GatewayReviewStatus.Pass when !string.IsNullOrEmpty(viewModel.OptionApprovedText):
            {
                var wordCount = viewModel.OptionApprovedText.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Length;
                if (wordCount > 150)
                {
                    validationResponse.Errors.Add(new ValidationErrorDetail("OptionApprovedText", TooManyWords150));
                }

                break;
            }
            }

            return(await Task.FromResult(validationResponse));
        }
コード例 #21
0
        public void ProcessViewModelOnError(RoatpGatewayApplicationViewModel viewModelOnError, RoatpGatewayApplicationViewModel viewModel, ValidationResponse validationResponse)
        {
            if (validationResponse.Errors != null && validationResponse.Errors.Any())
            {
                viewModelOnError.IsInvalid                  = true;
                viewModelOnError.ErrorMessages              = validationResponse.Errors;
                viewModelOnError.GatewayReviewStatus        = viewModel.GatewayReviewStatus;
                viewModelOnError.OptionAskClarificationText = viewModel.OptionAskClarificationText;
                viewModelOnError.OptionFailedText           = viewModel.OptionFailedText;
                viewModelOnError.OptionFailedExternalText   = viewModel.OptionFailedExternalText;
                viewModelOnError.OptionApprovedText         = viewModel.OptionApprovedText;
                viewModelOnError.OptionRejectedText         = viewModel.OptionRejectedText;
                viewModelOnError.OptionExternalRejectedText = viewModel.OptionExternalRejectedText;

                viewModelOnError.CssFormGroupError            = HtmlAndCssElements.CssFormGroupErrorClass;
                viewModelOnError.RadioCheckedAskClarification = viewModelOnError.GatewayReviewStatus == GatewayReviewStatus.ClarificationSent ? HtmlAndCssElements.CheckBoxChecked : string.Empty;
                viewModelOnError.RadioCheckedFailed           = viewModelOnError.GatewayReviewStatus == GatewayReviewStatus.Fail ? HtmlAndCssElements.CheckBoxChecked : string.Empty;
                viewModelOnError.RadioCheckedApproved         = viewModelOnError.GatewayReviewStatus == GatewayReviewStatus.Pass ? HtmlAndCssElements.CheckBoxChecked : string.Empty;
                viewModelOnError.RadioCheckedRejected         = viewModelOnError.GatewayReviewStatus == GatewayReviewStatus.Rejected ? HtmlAndCssElements.CheckBoxChecked : string.Empty;

                viewModelOnError.SubcontractingLimit = viewModel.SubcontractingLimit;
                viewModelOnError.RadioChecked100kSubcontractingLimit = viewModelOnError.SubcontractingLimit == 100000 ? HtmlAndCssElements.CheckBoxChecked : string.Empty;
                viewModelOnError.RadioChecked500kSubcontractingLimit = viewModelOnError.SubcontractingLimit == 500000 ? HtmlAndCssElements.CheckBoxChecked : string.Empty;

                foreach (var error in viewModelOnError.ErrorMessages)
                {
                    if (error.Field.Equals(nameof(viewModelOnError.GatewayReviewStatus)))
                    {
                        viewModelOnError.ErrorTextGatewayReviewStatus = error.ErrorMessage;
                    }

                    else if (error.Field.Equals(nameof(viewModelOnError.OptionAskClarificationText)))
                    {
                        viewModelOnError.ErrorTextAskClarification  = error.ErrorMessage;
                        viewModelOnError.CssOnErrorAskClarification = HtmlAndCssElements.CssTextareaErrorOverrideClass;
                    }

                    else if (error.Field.Equals(nameof(viewModelOnError.OptionFailedText)))
                    {
                        viewModelOnError.ErrorTextFailed  = error.ErrorMessage;
                        viewModelOnError.CssOnErrorFailed = HtmlAndCssElements.CssTextareaErrorOverrideClass;
                    }

                    else if (error.Field.Equals(nameof(viewModelOnError.OptionFailedExternalText)))
                    {
                        viewModelOnError.ErrorTextExternalFailed  = error.ErrorMessage;
                        viewModelOnError.CssOnErrorExternalFailed = HtmlAndCssElements.CssTextareaErrorOverrideClass;
                    }

                    else if (error.Field.Equals(nameof(viewModelOnError.OptionApprovedText)))
                    {
                        viewModelOnError.ErrorTextApproved  = error.ErrorMessage;
                        viewModelOnError.CssOnErrorApproved = HtmlAndCssElements.CssTextareaErrorOverrideClass;
                    }

                    else if (error.Field.Equals(nameof(viewModelOnError.OptionRejectedText)))
                    {
                        viewModelOnError.ErrorTextRejected  = error.ErrorMessage;
                        viewModelOnError.CssOnErrorRejected = HtmlAndCssElements.CssTextareaErrorOverrideClass;
                    }

                    else if (error.Field.Equals(nameof(viewModelOnError.OptionExternalRejectedText)))
                    {
                        viewModelOnError.ErrorTextExternalRejected  = error.ErrorMessage;
                        viewModelOnError.CssOnErrorExternalRejected = HtmlAndCssElements.CssTextareaErrorOverrideClass;
                    }

                    else if (error.Field.Equals(nameof(viewModelOnError.SubcontractingLimit)))
                    {
                        viewModelOnError.ErrorTextSubcontractingLimit = error.ErrorMessage;
                    }
                }
            }
        }
コード例 #22
0
        private async Task SetupNotRequiredLinkForOfficeForStudents(Guid applicationId, string userName, RoatpGatewayApplicationViewModel viewModel, int providerRoute)
        {
            var officeForStudentStatus = providerRoute == (int)ProviderTypes.Main ?  string.Empty : SectionReviewStatus.NotRequired;

            if (officeForStudentStatus.Equals(SectionReviewStatus.NotRequired))
            {
                var page = GetSectionByPageId(viewModel, GatewayPageIds.OfficeForStudents);

                if (page != null)
                {
                    page.Status = SectionReviewStatus.NotRequired;
                }
                _logger.LogInformation($"GetApplicationOverviewHandler-SubmitGatewayPageAnswer - ApplicationId '{applicationId}' - PageId '{GatewayPageIds.OfficeForStudents}' - Status '{SectionReviewStatus.NotRequired}' - UserName '{userName}' - PageData = 'null'");
                await _applyApiClient.SubmitGatewayPageAnswer(applicationId, GatewayPageIds.OfficeForStudents, SectionReviewStatus.NotRequired, null, null, null, null);
            }
        }
コード例 #23
0
        private async Task SetupNotRequiredLinkForInitialTeacherTraining(Guid applicationId, string userName, RoatpGatewayApplicationViewModel viewModel, int providerRoute)
        {
            var initialTeacherTrainingStatus = providerRoute == (int)ProviderTypes.Supporting ? SectionReviewStatus.NotRequired : string.Empty;

            if (initialTeacherTrainingStatus.Equals(SectionReviewStatus.NotRequired))
            {
                var page = GetSectionByPageId(viewModel, GatewayPageIds.InitialTeacherTraining);

                page.Status = SectionReviewStatus.NotRequired;

                _logger.LogInformation($"GetApplicationOverviewHandler-SubmitGatewayPageAnswer - ApplicationId '{applicationId}' - PageId '{GatewayPageIds.InitialTeacherTraining}' - Status '{SectionReviewStatus.NotRequired}' - UserName '{userName}' - PageData = 'null'");
                await _applyApiClient.SubmitGatewayPageAnswer(applicationId, GatewayPageIds.InitialTeacherTraining, SectionReviewStatus.NotRequired, null, null, null, null);
            }
        }
コード例 #24
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));
        }