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() { learnerRecord = new FindLearnerRecord { Uln = 1234567890, Name = "Test Name", IsLearnerRegistered = true, HasLrsEnglishAndMaths = true, IsSendConfirmationRequired = true }; ulnViewModel = new EnterUlnViewModel { EnterUln = "1234567890" }; englishAndMathsLrsQuestionViewModel = new EnglishAndMathsLrsQuestionViewModel { LearnerName = "Test Name", EnglishAndMathsLrsStatus = EnglishAndMathsLrsStatus.AchievedWithSend }; cacheResult = new AddLearnerRecordViewModel { LearnerRecord = learnerRecord, Uln = ulnViewModel, EnglishAndMathsLrsQuestion = englishAndMathsLrsQuestionViewModel, }; CacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey).Returns(cacheResult); }
public async Task <IActionResult> AddEnglishAndMathsLrsQuestionAsync(EnglishAndMathsLrsQuestionViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var cacheModel = await _cacheService.GetAsync <AddLearnerRecordViewModel>(CacheKey); if (cacheModel?.Uln == null) { return(RedirectToRoute(RouteConstants.PageNotFound)); } cacheModel.EnglishAndMathsLrsQuestion = model; await _cacheService.SetAsync(CacheKey, cacheModel); var response = await _trainingProviderLoader.AddLearnerRecordAsync(User.GetUkPrn(), cacheModel); if (response.IsSuccess) { if (cacheModel.Uln.IsNavigatedFromSearchLearnerRecordNotAdded) { await _cacheService.RemoveAsync <SearchLearnerRecordViewModel>(CacheKey); } await _cacheService.RemoveAsync <AddLearnerRecordViewModel>(CacheKey); await _cacheService.SetAsync(string.Concat(CacheKey, Constants.AddEnglishAndMathsSendDataConfirmation), new LearnerRecordConfirmationViewModel { Uln = response.Uln, Name = response.Name }, CacheExpiryTime.XSmall); return(RedirectToRoute(RouteConstants.AddEnglishAndMathsSendDataConfirmation)); } else { _logger.LogWarning(LogEvent.AddEnglishAndMathsSendDataEmailFailed, $"Unable to send email for English and maths send data for UniqueLearnerNumber: {cacheModel.Uln}. Method: AddEnglishAndMathsLrsQuestionAsync, Ukprn: {User.GetUkPrn()}, User: {User.GetUserEmail()}"); return(RedirectToRoute(RouteConstants.Error, new { StatusCode = 500 })); } }
public override void Given() { EnglishAndMathsLrsQuestionViewModel = new EnglishAndMathsLrsQuestionViewModel(); Controller.ModelState.AddModelError("EnglishAndMathsLrsStatus", EnglishAndMathsQuestionContent.Validation_Select_Is_EnglishMaths_Achieved_Required_Message); }