public override void Given()
        {
            _dateOfBirthViewModel = new DateofBirthViewModel {
                Day = DateTime.Now.Day.ToString(), Month = DateTime.Now.Month.ToString(), Year = DateTime.Now.Year.ToString()
            };
            _selectProviderViewModel = new SelectProviderViewModel {
                SelectedProviderUkprn = _providerUkprn.ToString(), ProvidersSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Hello", Value = "1"
                    }
                }
            };
            _selectCoreViewModel = new SelectCoreViewModel {
                CoreSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Education", Value = "123"
                    }
                }
            };
            cacheResult = new RegistrationViewModel
            {
                SelectProvider = _selectProviderViewModel
            };

            RegistrationLoader.GetRegisteredProviderPathwayDetailsAsync(Ukprn, _providerUkprn).Returns(_selectCoreViewModel);
            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
Пример #2
0
        public override void Given()
        {
            IsChangeMode  = true;
            _ulnViewModel = new UlnViewModel {
                Uln = "1234567890"
            };
            _learnersNameViewModel = new LearnersNameViewModel {
                Firstname = "First", Lastname = "Last"
            };
            _dateofBirthViewModel = new DateofBirthViewModel {
                Day = "01", Month = "01", Year = "2020"
            };
            _selectProviderViewModel = new SelectProviderViewModel {
                SelectedProviderUkprn = "98765432", SelectedProviderDisplayName = "Barnsley College (98765432)"
            };
            _selectCoreViewModel = new SelectCoreViewModel {
                SelectedCoreCode = _coreCode, SelectedCoreDisplayName = $"Education ({_coreCode})", CoreSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Education", Value = _coreCode
                    }
                }
            };

            cacheResult = new RegistrationViewModel
            {
                Uln            = _ulnViewModel,
                LearnersName   = _learnersNameViewModel,
                DateofBirth    = _dateofBirthViewModel,
                SelectProvider = _selectProviderViewModel,
                SelectCore     = _selectCoreViewModel
            };

            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
        public override void Given()
        {
            _selectedAcademicYear = ((int)AcademicYear.Year2020).ToString();
            _ulnViewModel         = new UlnViewModel {
                Uln = "1234567890"
            };
            _learnersNameViewModel = new LearnersNameViewModel {
                Firstname = "First", Lastname = "Last"
            };
            _dateofBirthViewModel = new DateofBirthViewModel {
                Day = "01", Month = "01", Year = "2020"
            };
            _selectProviderViewModel = new SelectProviderViewModel {
                SelectedProviderUkprn = "98765432", SelectedProviderDisplayName = "Barnsley College (98765432)"
            };
            _selectCoreViewModel = new SelectCoreViewModel {
                SelectedCoreCode = _coreCode, SelectedCoreDisplayName = $"Education ({_coreCode})", CoreSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Education", Value = _coreCode
                    }
                }
            };
            _specialismQuestionViewModel = new SpecialismQuestionViewModel {
                HasLearnerDecidedSpecialism = true
            };
            _pathwaySpecialismsViewModel = new PathwaySpecialismsViewModel {
                PathwayCode = _coreCode, PathwayName = "Education", Specialisms = new List <SpecialismDetailsViewModel> {
                    new SpecialismDetailsViewModel {
                        Code = "7654321", Name = "Test Education", DisplayName = "Test Education (7654321)", IsSelected = true
                    }
                }
            };
            _academicYearViewModel = new SelectAcademicYearViewModel {
                SelectedAcademicYear = _selectedAcademicYear.ToString()
            };

            cacheResult = new RegistrationViewModel
            {
                Uln                = _ulnViewModel,
                LearnersName       = _learnersNameViewModel,
                DateofBirth        = _dateofBirthViewModel,
                SelectProvider     = _selectProviderViewModel,
                SelectCore         = _selectCoreViewModel,
                SpecialismQuestion = _specialismQuestionViewModel,
                SelectAcademicYear = _academicYearViewModel
            };

            _pathwaySpecialismsViewModel = new PathwaySpecialismsViewModel {
                PathwayName = "Test Pathway", Specialisms = new List <SpecialismDetailsViewModel> {
                    new SpecialismDetailsViewModel {
                        Id = 1, Code = "345678", Name = "Test Specialism", DisplayName = "Test Specialism (345678)", IsSelected = true
                    }
                }
            };
            SelectSpecialismViewModel = new SelectSpecialismViewModel {
                IsChangeMode = true
            };
            RegistrationLoader.GetPathwaySpecialismsByPathwayLarIdAsync(Ukprn, _coreCode).Returns(_pathwaySpecialismsViewModel);
            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
        public override void Given()
        {
            IsChangeMode  = true;
            _ulnViewModel = new UlnViewModel {
                Uln = "1234567890"
            };
            _learnersNameViewModel = new LearnersNameViewModel {
                Firstname = "First", Lastname = "Last"
            };
            _dateofBirthViewModel = new DateofBirthViewModel {
                Day = "01", Month = "01", Year = "2020"
            };
            _selectProviderViewModel = new SelectProviderViewModel {
                SelectedProviderUkprn = "98765432", SelectedProviderDisplayName = "Barnsley College (98765432)", ProvidersSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Barnsley College (98765432)", Value = "98765432"
                    }
                }
            };

            cacheResult = new RegistrationViewModel
            {
                Uln            = _ulnViewModel,
                LearnersName   = _learnersNameViewModel,
                DateofBirth    = _dateofBirthViewModel,
                SelectProvider = _selectProviderViewModel
            };

            RegistrationLoader.GetRegisteredTqAoProviderDetailsAsync(Ukprn).Returns(_selectProviderViewModel);
            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
        public override void Given()
        {
            _routeAttributes = new Dictionary <string, string> {
                { Constants.IsChangeMode, "true" }
            };
            _ulnViewModel = new UlnViewModel {
                Uln = "1234567890"
            };
            _learnersNameViewModel = new LearnersNameViewModel {
                Firstname = "First", Lastname = "Last"
            };
            _dateofBirthViewModel = new DateofBirthViewModel {
                Day = "01", Month = "01", Year = "2020"
            };
            _selectProviderViewModel = new SelectProviderViewModel {
                SelectedProviderUkprn = "98765432", SelectedProviderDisplayName = "Barnsley College (98765432)"
            };
            _selectCoreViewModel = new SelectCoreViewModel {
                SelectedCoreCode = _coreCode, SelectedCoreDisplayName = $"Education ({_coreCode})", CoreSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Education", Value = _coreCode
                    }
                }
            };
            _specialismQuestionViewModel = new SpecialismQuestionViewModel {
                HasLearnerDecidedSpecialism = true
            };
            _pathwaySpecialismsViewModel = new PathwaySpecialismsViewModel {
                PathwayCode = _coreCode, PathwayName = "Education", Specialisms = new List <SpecialismDetailsViewModel> {
                    new SpecialismDetailsViewModel {
                        Code = "7654321", Name = "Test Education", DisplayName = "Test Education (7654321)", IsSelected = true
                    }
                }
            };
            _selectSpecialismViewModel = new SelectSpecialismViewModel {
                PathwaySpecialisms = _pathwaySpecialismsViewModel
            };
            _academicYearViewModel = new SelectAcademicYearViewModel {
                SelectedAcademicYear = "2020"
            };

            cacheResult = new RegistrationViewModel
            {
                Uln                = _ulnViewModel,
                LearnersName       = _learnersNameViewModel,
                DateofBirth        = _dateofBirthViewModel,
                SelectProvider     = _selectProviderViewModel,
                SelectCore         = _selectCoreViewModel,
                SpecialismQuestion = _specialismQuestionViewModel,
                SelectSpecialisms  = _selectSpecialismViewModel,
                SelectAcademicYear = _academicYearViewModel
            };

            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
        public override void Given()
        {
            _dateofBirthViewmodel = new DateofBirthViewModel {
                Day = "01", Month = "01", Year = "2020"
            };
            cacheResult = new RegistrationViewModel
            {
                LearnersName = new LearnersNameViewModel(),
                DateofBirth  = _dateofBirthViewmodel
            };

            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
        private bool IsValidDateofBirth(DateofBirthViewModel model)
        {
            var dateofBirth      = string.Concat(model.Day, "/", model.Month, "/", model.Year);
            var validationerrors = dateofBirth.ValidateDate("Date of birth");

            if (validationerrors?.Count == 0)
            {
                return(true);
            }

            foreach (var error in validationerrors)
            {
                ModelState.AddModelError(error.Key, error.Value);
            }

            return(false);
        }
Пример #8
0
        public override void Given()
        {
            _selectedAcademicYear = ((int)AcademicYear.Year2020).ToString();
            _ulnViewModel         = new UlnViewModel {
                Uln = "1234567890"
            };
            _learnersNameViewModel = new LearnersNameViewModel {
                Firstname = "First", Lastname = "Last"
            };
            _dateofBirthViewModel = new DateofBirthViewModel {
                Day = "01", Month = "01", Year = "2020"
            };
            _selectProviderViewModel = new SelectProviderViewModel {
                SelectedProviderUkprn = "98765432", SelectedProviderDisplayName = "Barnsley College (98765432)"
            };
            _selectCoreViewModel = new SelectCoreViewModel {
                SelectedCoreCode = _coreCode, SelectedCoreDisplayName = $"Education ({_coreCode})", CoreSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Education", Value = _coreCode
                    }
                }
            };
            _specialismQuestionViewModel = new SpecialismQuestionViewModel {
                HasLearnerDecidedSpecialism = true
            };
            _academicYearViewModel = new SelectAcademicYearViewModel {
                SelectedAcademicYear = _selectedAcademicYear.ToString()
            };

            cacheResult = new RegistrationViewModel
            {
                Uln                = _ulnViewModel,
                LearnersName       = _learnersNameViewModel,
                DateofBirth        = _dateofBirthViewModel,
                SelectProvider     = _selectProviderViewModel,
                SelectCore         = _selectCoreViewModel,
                SpecialismQuestion = _specialismQuestionViewModel,
                SelectAcademicYear = _academicYearViewModel
            };

            SpecialismQuestionViewModel = new SpecialismQuestionViewModel {
                HasLearnerDecidedSpecialism = false, IsChangeMode = true
            };
            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
        public override void Given()
        {
            _dateOfBirthViewModel    = new DateofBirthViewModel();
            _selectProviderViewModel = new SelectProviderViewModel {
                ProvidersSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Hello", Value = "1"
                    }
                }
            };

            cacheResult = new RegistrationViewModel
            {
                DateofBirth = _dateOfBirthViewModel
            };

            RegistrationLoader.GetRegisteredTqAoProviderDetailsAsync(Ukprn).Returns(_selectProviderViewModel);
            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
        public async Task <IActionResult> AddRegistrationDateofBirthAsync(DateofBirthViewModel model)
        {
            if (!IsValidDateofBirth(model))
            {
                return(View(model));
            }

            var cacheModel = await _cacheService.GetAsync <RegistrationViewModel>(CacheKey);

            if (model == null || cacheModel?.LearnersName == null)
            {
                return(RedirectToRoute(RouteConstants.PageNotFound));
            }

            cacheModel.DateofBirth = model;
            await _cacheService.SetAsync(CacheKey, cacheModel);

            return(model.IsChangeMode ? RedirectToRoute(RouteConstants.AddRegistrationCheckAndSubmit) : RedirectToRoute(RouteConstants.AddRegistrationProvider));
        }
        public override void Given()
        {
            _ulnViewModel = new UlnViewModel {
                Uln = "1234567890"
            };
            _learnersNameViewModel = new LearnersNameViewModel {
                Firstname = "First", Lastname = "Last"
            };
            DateofBirthViewmodel = new DateofBirthViewModel {
                Day = "01", Month = "01", Year = "2020", IsChangeMode = true
            };

            cacheResult = new RegistrationViewModel
            {
                Uln          = _ulnViewModel,
                LearnersName = _learnersNameViewModel,
                DateofBirth  = DateofBirthViewmodel
            };

            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
 public override void Given()
 {
     DateofBirthViewmodel = new DateofBirthViewModel {
         Day = "d2", Month = "m1", Year = "yy00"
     };
 }
 public IViewComponentResult Invoke(DateofBirthViewModel model)
 {
     return(View("~/ViewComponents/Registration/DateofBirth/Index.cshtml", model));
 }
Пример #14
0
 public override void Given()
 {
     DateofBirthViewmodel = new DateofBirthViewModel {
         Day = "01", Month = "01", Year = "2020"
     };
 }