public async Task PostConfirmEditModelAsync_ShouldFlagProviderFieldIndicator(long ukprn)
        {
            var fixture = new TrainingProviderOrchestratorTestsFixture();

            fixture
            .WithVacacny(
                new Vacancy
            {
                Id = fixture.VacancyId,
                EmployerAccountId = TrainingProviderOrchestratorTestsFixture.EmployerAccountId,
                TrainingProvider  = new TrainingProvider(),
                Title             = "specified for route validation",
                ProgrammeId       = "specified for route validation"
            })
            .Setup();

            var confirmTrainingProviderEditModel = new ConfirmTrainingProviderEditModel
            {
                EmployerAccountId = TrainingProviderOrchestratorTestsFixture.EmployerAccountId,
                VacancyId         = fixture.Vacancy.Id,
                Ukprn             = ukprn.ToString()
            };

            await fixture.PostConfirmEditModelAsync(confirmTrainingProviderEditModel);

            fixture.VerifyEmployerReviewFieldIndicators(FieldIdentifiers.Provider, true);
        }
        public async Task <IActionResult> ConfirmTrainingProvider(ConfirmTrainingProviderEditModel m)
        {
            if (!ModelState.IsValid)
            {
                return(View(m));
            }

            var providerExists = await _orchestrator.ConfirmProviderExists(long.Parse(m.Ukprn));

            if (providerExists == false)
            {
                var vm = new SelectTrainingProviderEditModel {
                    VacancyId = m.VacancyId, Ukprn = m.Ukprn
                };
                return(await ProviderNotFound(vm));
            }

            var response = await _orchestrator.PostConfirmEditModelAsync(m, User.ToVacancyUser());

            if (!response.Success)
            {
                response.AddErrorsToModelState(ModelState);
            }

            if (!ModelState.IsValid)
            {
                var vm = await _orchestrator.GetSelectTrainingProviderViewModel(m);

                return(View(ViewNames.SelectTrainingProvider, vm));
            }

            return(RedirectToRoute(RouteNames.Vacancy_Preview_Get));
        }
Exemplo n.º 3
0
        public void ShouldBeValidIfUkprnSpecified()
        {
            var vm = new ConfirmTrainingProviderEditModel
            {
                Ukprn = "12345678"
            };

            var validator = new ConfirmTrainingProviderEditModelValidator();

            var result = validator.Validate(vm);

            result.IsValid.Should().BeTrue();
        }
Exemplo n.º 4
0
        public void ShouldBeValidIfUkprnSpecified()
        {
            var vm = new ConfirmTrainingProviderEditModel
            {
                Ukprn = "12345678"
            };

            var context = new ValidationContext(vm, null, null);
            var result  = new List <ValidationResult>();

            var isValid = Validator.TryValidateObject(vm, context, result, true);

            isValid.Should().BeTrue();
        }
Exemplo n.º 5
0
        public void ShouldErrorIfUkprnIsInvalid()
        {
            var vm = new ConfirmTrainingProviderEditModel {
                Ukprn = "invalid ukprn"
            };

            var validator = new ConfirmTrainingProviderEditModelValidator();

            var result = validator.Validate(vm);

            result.IsValid.Should().BeFalse();
            result.Errors.Count.Should().Be(1);
            result.Errors[0].PropertyName.Should().Be("Ukprn");
            result.Errors[0].ErrorMessage.Should().Be("UKPRN is not recognised");
        }
Exemplo n.º 6
0
        public void ShouldErrorIfUkprnIsNotSpecified(string inputUkprn)
        {
            var vm = new ConfirmTrainingProviderEditModel
            {
                Ukprn = inputUkprn
            };

            var context = new ValidationContext(vm, null, null);
            var result  = new List <ValidationResult>();

            var isValid = Validator.TryValidateObject(vm, context, result, true);

            isValid.Should().BeFalse();
            result.Single(r => r.MemberNames.Single() == "Ukprn").ErrorMessage.Should().Be("The UKPRN field is required.");
        }
Exemplo n.º 7
0
        public void ShouldErrorIfUkprnIsNotSpecified(string inputUkprn)
        {
            var vm = new ConfirmTrainingProviderEditModel
            {
                Ukprn = inputUkprn
            };

            var validator = new ConfirmTrainingProviderEditModelValidator();

            var result = validator.Validate(vm);

            result.IsValid.Should().BeFalse();
            result.Errors.Count.Should().Be(1);
            result.Errors[0].PropertyName.Should().Be("Ukprn");
            result.Errors[0].ErrorMessage.Should().Be("The UKPRN field is required");
        }
        public async Task <IActionResult> ConfirmTrainingProvider(ConfirmTrainingProviderEditModel m, [FromQuery] bool wizard)
        {
            if (ModelState.IsValid)
            {
                var response = await _orchestrator.PostConfirmEditModelAsync(m, User.ToVacancyUser());

                if (response.Success)
                {
                    return(GetRedirectToNextPage(wizard));
                }

                AddTrainingProviderErrorsToModelState(TrainingProviderSelectionType.Ukprn, m.Ukprn, response, ModelState);
            }

            var vm = await _orchestrator.GetSelectTrainingProviderViewModelAsync(m);

            vm.PageInfo.SetWizard(wizard);
            return(View(ViewNames.SelectTrainingProvider, vm));
        }
 public async Task <OrchestratorResponse> PostConfirmEditModelAsync(ConfirmTrainingProviderEditModel model)
 {
     return(await Sut.PostConfirmEditModelAsync(model, User));
 }