public override void Given()
        {
            _routeAttributes = new Dictionary <string, string> {
                { Constants.IsChangeMode, "true" }
            };
            _learnerRecord = new FindLearnerRecord {
                Uln = 1234567890, Name = "Test Name", DateofBirth = DateTime.UtcNow.AddYears(-30), ProviderName = "Barnsley College (123456789)", PathwayName = "Digital Services (1234786)", IsLearnerRegistered = true, IsLearnerRecordAdded = false, HasLrsEnglishAndMaths = false
            };
            _ulnViewModel = new EnterUlnViewModel {
                EnterUln = "1234567890"
            };
            _englishAndMathsViewModel = new EnglishAndMathsQuestionViewModel {
                LearnerName = _learnerRecord.Name, EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved
            };
            IndustryPlacementQuestionViewModel = new IndustryPlacementQuestionViewModel {
                LearnerName = _learnerRecord.Name, IndustryPlacementStatus = IndustryPlacementStatus.NotCompleted
            };

            _cacheResult = new AddLearnerRecordViewModel
            {
                LearnerRecord             = _learnerRecord,
                Uln                       = _ulnViewModel,
                EnglishAndMathsQuestion   = _englishAndMathsViewModel,
                IndustryPlacementQuestion = IndustryPlacementQuestionViewModel
            };

            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(_cacheResult);
        }
        public override void Given()
        {
            LearnerRecord = new FindLearnerRecord {
                Uln = 1234567890, Name = "Test Name", DateofBirth = DateTime.UtcNow.AddYears(-30), ProviderName = "Barnsley College (123456789)", IsLearnerRegistered = true, IsLearnerRecordAdded = false, HasLrsEnglishAndMaths = true
            };
            EnterUlnViewModel = new EnterUlnViewModel {
                EnterUln = "1234567890"
            };
            EnglishAndMathsLrsQuestionViewModel = new EnglishAndMathsLrsQuestionViewModel {
                EnglishAndMathsLrsStatus = EnglishAndMathsLrsStatus.AchievedWithSend
            };

            AddLearnerRecordViewModel = new AddLearnerRecordViewModel
            {
                LearnerRecord = LearnerRecord,
                Uln           = EnterUlnViewModel,
                EnglishAndMathsLrsQuestion = EnglishAndMathsLrsQuestionViewModel
            };

            AddLearnerRecordResponse = new AddLearnerRecordResponse
            {
                IsSuccess = false
            };

            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(AddLearnerRecordViewModel);
            TrainingProviderLoader.AddLearnerRecordAsync(ProviderUkprn, AddLearnerRecordViewModel).Returns(AddLearnerRecordResponse);
        }
        public override void Given()
        {
            EnglishAndMathsQuestionViewModel = new EnglishAndMathsQuestionViewModel {
                EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved, IsChangeMode = true
            };
            _learnerRecord = new FindLearnerRecord {
                Uln = 1234567890, Name = "Test Name", IsLearnerRegistered = true, IsLearnerRecordAdded = false
            };
            _ulnViewModel = new EnterUlnViewModel {
                EnterUln = "1234567890"
            };
            _industryPlacementQuestionViewModel = new IndustryPlacementQuestionViewModel {
                LearnerName = _learnerRecord.Name, IndustryPlacementStatus = IndustryPlacementStatus.Completed
            };

            _cacheResult = new AddLearnerRecordViewModel
            {
                LearnerRecord             = _learnerRecord,
                Uln                       = _ulnViewModel,
                EnglishAndMathsQuestion   = EnglishAndMathsQuestionViewModel,
                IndustryPlacementQuestion = _industryPlacementQuestionViewModel
            };

            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(_cacheResult);
        }
예제 #4
0
        public async Task <IActionResult> EnterUniqueLearnerReferenceAsync(EnterUlnViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var learnerRecord = await _trainingProviderLoader.FindLearnerRecordAsync(User.GetUkPrn(), model.EnterUln.ToLong(), evaluateSendConfirmation : true);

            if (learnerRecord == null || !learnerRecord.IsLearnerRegistered || learnerRecord.IsLearnerRecordAdded)
            {
                await SyncCacheUln(model, learnerRecord);

                if (learnerRecord == null || learnerRecord.IsLearnerRegistered == false)
                {
                    return(RedirectToRoute(RouteConstants.EnterUniqueLearnerNumberNotFound));
                }
                else
                {
                    return(RedirectToRoute(RouteConstants.EnterUniqueLearnerNumberAddedAlready, new { profileId = learnerRecord.ProfileId }));
                }
            }

            await SyncCacheUln(model, learnerRecord);

            if (learnerRecord.HasLrsEnglishAndMaths)
            {
                return(RedirectToRoute(learnerRecord.IsSendConfirmationRequired ? RouteConstants.AddEnglishAndMathsLrsQuestion : RouteConstants.AddIndustryPlacementQuestion));
            }
            else
            {
                return(RedirectToRoute(RouteConstants.AddEnglishAndMathsQuestion));
            }
        }
        public override void Given()
        {
            var uln = string.Empty;

            EnterUlnViewModel = new EnterUlnViewModel {
                EnterUln = uln
            };
            Controller.ModelState.AddModelError("EnterUln", EnterUlnContent.Uln_Required_Validation_Message);
        }
        public override void Given()
        {
            var uln = "InvalidText";

            EnterUlnViewModel = new EnterUlnViewModel {
                EnterUln = uln
            };
            Controller.ModelState.AddModelError("EnterUln", EnterUlnContent.Uln_Not_Valid_Validation_Message);
        }
 public override void Given()
 {
     EnterUlnViewModel = new EnterUlnViewModel {
         EnterUln = uln.ToString()
     };
     mockResult = new FindLearnerRecord {
         IsLearnerRegistered = false
     };
     TrainingProviderLoader.FindLearnerRecordAsync(ProviderUkprn, uln, _evaluteSendConfirmation).Returns(mockResult);
 }
 public override void Given()
 {
     _profileId        = 1;
     EnterUlnViewModel = new EnterUlnViewModel {
         EnterUln = _uln.ToString()
     };
     _mockResult = new FindLearnerRecord {
         ProfileId = _profileId, IsLearnerRegistered = true, IsLearnerRecordAdded = true
     };
     TrainingProviderLoader.FindLearnerRecordAsync(ProviderUkprn, _uln, _evaluteSendConfirmation).Returns(_mockResult);
 }
        public override void Given()
        {
            _ulnViewModel = new EnterUlnViewModel {
                EnterUln = "9895641231"
            };
            var cacheModel = new AddLearnerRecordViewModel {
                Uln = _ulnViewModel
            };

            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(cacheModel);
        }
예제 #10
0
        public override void Given()
        {
            IsNavigatedFromSearchLearnerRecordNotAdded = true;
            _ulnViewModel = new EnterUlnViewModel {
                EnterUln = "9895641231"
            };
            var cacheModel = new AddLearnerRecordViewModel {
                Uln = _ulnViewModel
            };

            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(cacheModel);
        }
        public override void Given()
        {
            EnterUlnViewModel = new EnterUlnViewModel {
                EnterUln = uln.ToString()
            };
            TrainingProviderLoader.FindLearnerRecordAsync(ProviderUkprn, uln, _evaluteSendConfirmation).Returns(mockResult);

            mockCacheViewModel = new AddLearnerRecordViewModel {
                LearnerRecord = mockResult
            };
            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(mockCacheViewModel);
        }
        public override void Given()
        {
            _ulnViewModel = new EnterUlnViewModel {
                EnterUln = "1234567890"
            };

            _cacheResult = new AddLearnerRecordViewModel
            {
                Uln = _ulnViewModel
            };

            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(_cacheResult);
        }
        public override void Given()
        {
            learnerRecord = new FindLearnerRecord {
                Uln = 1234567890, Name = "Test Name", IsLearnerRegistered = true, HasLrsEnglishAndMaths = true, IsSendConfirmationRequired = true
            };
            ulnViewModel = new EnterUlnViewModel {
                EnterUln = "1234567890"
            };
            cacheResult = new AddLearnerRecordViewModel
            {
                LearnerRecord = learnerRecord,
                Uln           = ulnViewModel,
            };

            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(cacheResult);
        }
예제 #14
0
        public override void Given()
        {
            _learnerRecord = new FindLearnerRecord {
                Uln = 1234567890, Name = "Test Name", IsLearnerRegistered = true, HasLrsEnglishAndMaths = true, IsSendConfirmationRequired = false
            };
            EnterUlnViewModel = new EnterUlnViewModel {
                EnterUln = _uln.ToString()
            };

            var cacheModel = new AddLearnerRecordViewModel {
                LearnerRecord = _learnerRecord, Uln = EnterUlnViewModel
            };

            TrainingProviderLoader.FindLearnerRecordAsync(ProviderUkprn, _uln, _evaluateSendConfirmation).Returns(_learnerRecord);
            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(cacheModel);
        }
예제 #15
0
        public override void Given()
        {
            _learnerRecord = new FindLearnerRecord {
                Uln = 1234567890, Name = "Test Name", IsLearnerRegistered = false
            };
            _ulnViewModel = new EnterUlnViewModel {
                EnterUln = "1234567890"
            };

            _cacheResult = new AddLearnerRecordViewModel
            {
                LearnerRecord = _learnerRecord,
                Uln           = _ulnViewModel
            };

            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(_cacheResult);
        }
예제 #16
0
        private async Task SyncCacheUln(EnterUlnViewModel model, FindLearnerRecord learnerRecord = null)
        {
            var cacheModel = await _cacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey);

            if (cacheModel?.Uln != null && cacheModel?.Uln?.EnterUln == model.EnterUln)
            {
                cacheModel.LearnerRecord = learnerRecord;
                cacheModel.Uln           = model;
            }
            else
            {
                cacheModel = new AddLearnerRecordViewModel {
                    LearnerRecord = learnerRecord, Uln = model
                }
            };

            await _cacheService.SetAsync(CacheKey, cacheModel);
        }
    }
        public override void Given()
        {
            learnerRecord = new FindLearnerRecord {
                Uln = 1234567890, Name = "Test Name", IsLearnerRegistered = true, IsLearnerRecordAdded = false
            };
            ulnViewModel = new EnterUlnViewModel {
                EnterUln = "1234567890"
            };
            EnglishAndMathsQuestionViewModel = new EnglishAndMathsQuestionViewModel {
                EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved
            };

            _cacheResult = new AddLearnerRecordViewModel
            {
                LearnerRecord = learnerRecord,
                Uln           = ulnViewModel
            };

            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(_cacheResult);
        }
        public override void Given()
        {
            _searchLearnerRecordViewModel = new SearchLearnerRecordViewModel {
                SearchUln = "1234567890"
            };
            LearnerRecord = new FindLearnerRecord {
                Uln = 1234567890, Name = "Test Name", DateofBirth = DateTime.UtcNow.AddYears(-30), ProviderName = "Barnsley College (123456789)", IsLearnerRegistered = true, IsLearnerRecordAdded = false, HasLrsEnglishAndMaths = false
            };
            EnterUlnViewModel = new EnterUlnViewModel {
                EnterUln = _searchLearnerRecordViewModel.SearchUln, IsNavigatedFromSearchLearnerRecordNotAdded = true
            };
            EnglishAndMathsQuestionViewModel = new EnglishAndMathsQuestionViewModel {
                EnglishAndMathsStatus = EnglishAndMathsStatus.AchievedWithSend
            };
            IndustryPlacementQuestionViewModel = new IndustryPlacementQuestionViewModel {
                LearnerName = LearnerRecord.Name, IndustryPlacementStatus = IndustryPlacementStatus.Completed
            };

            AddLearnerRecordViewModel = new AddLearnerRecordViewModel
            {
                LearnerRecord             = LearnerRecord,
                Uln                       = EnterUlnViewModel,
                EnglishAndMathsQuestion   = EnglishAndMathsQuestionViewModel,
                IndustryPlacementQuestion = IndustryPlacementQuestionViewModel
            };

            AddLearnerRecordResponse = new AddLearnerRecordResponse
            {
                IsSuccess = true,
                Uln       = LearnerRecord.Uln,
                Name      = LearnerRecord.Name
            };


            CacheService.GetAsync <SearchLearnerRecordViewModel>(CacheKey).Returns(_searchLearnerRecordViewModel);
            CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(AddLearnerRecordViewModel);
            TrainingProviderLoader.AddLearnerRecordAsync(ProviderUkprn, AddLearnerRecordViewModel).Returns(AddLearnerRecordResponse);
        }