public async Task <IActionResult> Wage(WageEditModel m, [FromQuery] bool wizard)
        {
            var response = await _orchestrator.PostWageEditModelAsync(m, User.ToVacancyUser());

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

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

                vm.PageInfo.SetWizard(wizard);
                return(View(vm));
            }

            if (_feature.IsFeatureEnabled(FeatureNames.EmployerTaskList))
            {
                if (wizard)
                {
                    return(RedirectToRoute(RouteNames.NumberOfPositions_Get));
                }
                return(RedirectToRoute(RouteNames.EmployerCheckYourAnswersGet));
            }

            return(wizard
                ? RedirectToRoute(RouteNames.Part1Complete_Get)
                : RedirectToRoute(RouteNames.Vacancy_Preview_Get));
        }
예제 #2
0
        public void ShouldErrorIfEmployerEditModelIsInvalid(string propertyName, object actualPropertyValue, string expectedErrorMessage)
        {
            //a valid model
            var m = new WageEditModel
            {
                EmployerAccountId         = "valid",
                VacancyId                 = Guid.Parse("53b54daa-4702-4b69-97e5-12123a59f8ad"),
                Duration                  = "1",
                DurationUnit              = DurationUnit.Year,
                WorkingWeekDescription    = "valid",
                WeeklyHours               = "35.25",
                WageType                  = WageType.FixedWage,
                FixedWageYearlyAmount     = "20,000.43",
                WageAdditionalInformation = "valid"
            };

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

            //ensure we are starting with a valid model
            var isInitiallyValid = Validator.TryValidateObject(m, context, result, true);

            isInitiallyValid.Should().BeTrue();

            //set the property we are testing
            m.GetType().GetProperty(propertyName).SetValue(m, actualPropertyValue);

            // Act
            var isValid = Validator.TryValidateObject(m, context, result, true);

            isValid.Should().BeFalse();
            result.Should().HaveCount(1);
            result.Single(r => r.MemberNames.Single() == propertyName).ErrorMessage.Should().Be(expectedErrorMessage);
        }
예제 #3
0
        public void FixedWage_ShouldErrorIfInvalid(string fixedWageYearlyAmount, string expectedErrorMessage)
        {
            var m = new WageEditModel
            {
                EmployerAccountId         = "valid",
                VacancyId                 = Guid.Parse("53b54daa-4702-4b69-97e5-12123a59f8ad"),
                WageType                  = WageType.FixedWage,
                FixedWageYearlyAmount     = fixedWageYearlyAmount,
                WageAdditionalInformation = "valid"
            };

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

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

            isValid.Should().BeFalse();
            result.Should().HaveCount(1);
            result[0].ErrorMessage.Should().Be(expectedErrorMessage);
        }
예제 #4
0
        public async Task WhenUpdated_ShouldFlagFieldIndicators(WageType wageType, decimal fixedWageYearlyAmmount, string wageAddtionalInformation, bool fieldIndicatorSet)
        {
            _fixture
            .WithWageType(WageType.FixedWage)
            .WithFixedWageYearlyAmount(10000)
            .WithWageAdditionalInformation("this is a value")
            .Setup();

            var wageEditModel = new WageEditModel
            {
                Ukprn                     = _fixture.Vacancy.TrainingProvider.Ukprn.Value,
                VacancyId                 = _fixture.Vacancy.Id,
                WageType                  = wageType,
                FixedWageYearlyAmount     = fixedWageYearlyAmmount.ToString(),
                WageAdditionalInformation = wageAddtionalInformation
            };

            await _fixture.PostWageEditModelAsync(wageEditModel);

            _fixture.VerifyProviderReviewFieldIndicators(FieldIdentifiers.Wage, fieldIndicatorSet);
        }
        public async Task <IActionResult> Wage(WageEditModel m, [FromQuery] bool wizard)
        {
            var response = await _orchestrator.PostWageEditModelAsync(m, User.ToVacancyUser());

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

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

                vm.PageInfo.SetWizard(wizard);
                return(View(vm));
            }

            return(wizard
                ? RedirectToRoute(RouteNames.Part1Complete_Get)
                : RedirectToRoute(RouteNames.Vacancy_Preview_Get));
        }
예제 #6
0
 public async Task PostWageEditModelAsync(WageEditModel model)
 {
     await Sut.PostWageEditModelAsync(model, User);
 }