Пример #1
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 async Task <IActionResult> AddRegistrationUlnAsync(UlnViewModel model)
        {
            if (model == null)
            {
                return(RedirectToRoute(RouteConstants.PageNotFound));
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await SyncCacheUln(model);

            var findUln = await _registrationLoader.FindUlnAsync(User.GetUkPrn(), model.Uln.ToLong());

            if (findUln != null && findUln.IsUlnRegisteredAlready)
            {
                findUln.IsChangeMode = model.IsChangeMode;
                await _cacheService.SetAsync(string.Concat(CacheKey, Constants.UlnRegistrationNotFoundViewModel), findUln, CacheExpiryTime.XSmall);

                return(RedirectToRoute(RouteConstants.UlnCannotBeRegistered));
            }

            return(model.IsChangeMode ? RedirectToRoute(RouteConstants.AddRegistrationCheckAndSubmit) : RedirectToRoute(RouteConstants.AddRegistrationLearnersName));
        }
Пример #3
0
 public override void Given()
 {
     UlnViewModel = new UlnViewModel {
         Uln = "HelloWorld"
     };
     Controller.ModelState.AddModelError("Uln", UlnContent.Validation_Uln_Must_Be_Digits);
 }
        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()
        {
            _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()
        {
            _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);
        }
Пример #7
0
        public override void Given()
        {
            _ulnViewModel = new UlnViewModel {
                Uln = "1234567890"
            };
            RegistrationViewModel cacheModel = new RegistrationViewModel {
                Uln = _ulnViewModel
            };

            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheModel);
        }
        public override void Given()
        {
            var findUln = new UlnRegistrationNotFoundViewModel
            {
                IsAllowed = true
            };

            UlnViewModel = new UlnViewModel {
                Uln = "1234567890"
            };
            RegistrationLoader.FindUlnAsync(Arg.Any <long>(), Arg.Any <long>()).Returns(findUln);
        }
Пример #9
0
        public override void Given()
        {
            IsChangeMode  = true;
            _ulnViewModel = new UlnViewModel {
                Uln = "1234567890"
            };

            cacheResult = new RegistrationViewModel
            {
                Uln = _ulnViewModel
            };

            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
        public override void Given()
        {
            UlnViewModel = new UlnViewModel {
                Uln = "1234567890"
            };
            LearnersNameViewModel = new LearnersNameViewModel {
                Firstname = "First", Lastname = "Last", IsChangeMode = true
            };

            var cacheResult = new RegistrationViewModel
            {
                Uln          = UlnViewModel,
                LearnersName = LearnersNameViewModel
            };

            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
        private async Task SyncCacheUln(UlnViewModel model)
        {
            var cacheModel = await _cacheService.GetAsync <RegistrationViewModel>(CacheKey);

            if (cacheModel?.Uln != null)
            {
                cacheModel.Uln = model;
            }
            else
            {
                cacheModel = new RegistrationViewModel {
                    Uln = model
                }
            };

            await _cacheService.SetAsync(CacheKey, cacheModel);
        }
        public override void Given()
        {
            _ulnViewModel = new UlnViewModel {
                Uln = "1234567890"
            };
            _learnersNameViewModel = new LearnersNameViewModel {
                Firstname = "First", Lastname = "Last"
            };

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

            CacheService.GetAsync <RegistrationViewModel>(CacheKey).Returns(cacheResult);
        }
Пример #13
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()
        {
            _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);
        }
Пример #15
0
 public override void Given()
 {
     UlnViewModel = new UlnViewModel();
     Controller.ModelState.AddModelError("Uln", UlnContent.Validation_Uln_Required);
 }
 public override void Given()
 {
     UlnViewModel = new UlnViewModel {
         Uln = "1234567890", IsChangeMode = true
     };
 }
Пример #17
0
 public override void Given()
 {
     UlnViewModel = new UlnViewModel {
         Uln = "1234567890"
     };
 }
 public IViewComponentResult Invoke(UlnViewModel model)
 {
     return(View("~/ViewComponents/Registration/Uln/Index.cshtml", model));
 }