예제 #1
0
        public async Task <IActionResult> UpdateEnglisAndMathsAchievementAsync(UpdateEnglishAndMathsQuestionViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var response = await _trainingProviderLoader.ProcessEnglishAndMathsQuestionUpdateAsync(User.GetUkPrn(), viewModel);

            if (response == null)
            {
                return(RedirectToRoute(RouteConstants.ProblemWithService));
            }

            if (!response.IsModified)
            {
                return(RedirectToRoute(RouteConstants.LearnerRecordDetails, new { viewModel.ProfileId }));
            }

            if (!response.IsSuccess)
            {
                return(RedirectToRoute(RouteConstants.ProblemWithService));
            }

            await _cacheService.SetAsync(string.Concat(CacheKey, Constants.EnglishAndMathsAchievementUpdatedConfirmation), response, CacheExpiryTime.XSmall);

            return(RedirectToRoute(RouteConstants.EnglishAndMathsAchievementUpdatedConfirmation));
        }
 public override void Given()
 {
     ProviderUkprn      = 87945612;
     ProfileId          = 0;
     _expectedApiResult = null;
     ViewModel          = new UpdateEnglishAndMathsQuestionViewModel {
         ProfileId = ProfileId, EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved
     };
     InternalApiClient.GetLearnerRecordDetailsAsync(ProviderUkprn, ProfileId).Returns(_expectedApiResult);
 }
 public override void Given()
 {
     ProfileId  = 10;
     mockresult = new UpdateEnglishAndMathsQuestionViewModel
     {
         ProfileId            = ProfileId,
         IsLearnerRecordAdded = false
     };
     TrainingProviderLoader.GetLearnerRecordDetailsAsync <UpdateEnglishAndMathsQuestionViewModel>(ProviderUkprn, ProfileId).Returns(mockresult);
 }
 public override void Given()
 {
     ProfileId  = 10;
     mockresult = new UpdateEnglishAndMathsQuestionViewModel
     {
         ProfileId             = ProfileId,
         LearnerName           = "Test user",
         IsLearnerRecordAdded  = true,
         EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved
     };
     TrainingProviderLoader.GetLearnerRecordDetailsAsync <UpdateEnglishAndMathsQuestionViewModel>(ProviderUkprn, ProfileId).Returns(mockresult);
 }
예제 #5
0
 public override void Given()
 {
     ProviderUkprn      = 87945612;
     ProfileId          = 1;
     _expectedApiResult = new LearnerRecordDetails {
         ProfileId = 1, IsLearnerRecordAdded = true, HasLrsEnglishAndMaths = false, IsEnglishAndMathsAchieved = true, IsSendLearner = false
     };
     ViewModel = new UpdateEnglishAndMathsQuestionViewModel {
         ProfileId = 1, EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved
     };
     InternalApiClient.GetLearnerRecordDetailsAsync(ProviderUkprn, ProfileId).Returns(_expectedApiResult);
 }
예제 #6
0
        public override void Given()
        {
            _updateLearnerRecordResponse = null;

            ViewModel = new UpdateEnglishAndMathsQuestionViewModel
            {
                ProfileId             = 1,
                EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved
            };

            TrainingProviderLoader.ProcessEnglishAndMathsQuestionUpdateAsync(ProviderUkprn, ViewModel).Returns(_updateLearnerRecordResponse);
        }
        public override void Given()
        {
            _updateLearnerRecordResponse = new UpdateLearnerRecordResponseViewModel
            {
                ProfileId  = 1,
                Uln        = 1234567890,
                Name       = "Test User",
                IsModified = true,
                IsSuccess  = true
            };

            ViewModel = new UpdateEnglishAndMathsQuestionViewModel
            {
                ProfileId             = 1,
                EnglishAndMathsStatus = EnglishAndMathsStatus.Achieved
            };

            TrainingProviderLoader.ProcessEnglishAndMathsQuestionUpdateAsync(ProviderUkprn, ViewModel).Returns(_updateLearnerRecordResponse);
        }
        public override void Given()
        {
            CreateMapper();
            ProviderUkprn = 987654321;
            ProfileId     = 1;

            _expectedApiResult = new LearnerRecordDetails {
                ProfileId = ProfileId, Uln = 1234567890, Name = "Test User", IsLearnerRecordAdded = true, HasLrsEnglishAndMaths = false, IsEnglishAndMathsAchieved = true, IsSendLearner = false
            };
            ViewModel = new UpdateEnglishAndMathsQuestionViewModel {
                ProfileId = ProfileId, EnglishAndMathsStatus = EnglishAndMathsStatus.AchievedWithSend
            };

            InternalApiClient.GetLearnerRecordDetailsAsync(ProviderUkprn, ProfileId).Returns(_expectedApiResult);
            InternalApiClient.UpdateLearnerRecordAsync(Arg.Is <UpdateLearnerRecordRequest>
                                                           (x => x.ProfileId == ViewModel.ProfileId &&
                                                           x.Ukprn == ProviderUkprn &&
                                                           x.Uln == _expectedApiResult.Uln &&
                                                           x.EnglishAndMathsStatus == ViewModel.EnglishAndMathsStatus &&
                                                           x.PerformedBy == $"{Givenname} {Surname}"))
            .Returns(true);

            Loader = new TrainingProviderLoader(InternalApiClient, Mapper);
        }
        public async Task <UpdateLearnerRecordResponseViewModel> ProcessEnglishAndMathsQuestionUpdateAsync(long providerUkprn, UpdateEnglishAndMathsQuestionViewModel viewModel)
        {
            var response = await _internalApiClient.GetLearnerRecordDetailsAsync(providerUkprn, viewModel.ProfileId);

            if (response == null || !response.IsLearnerRecordAdded || response.HasLrsEnglishAndMaths)
            {
                return(null);
            }

            var englishAndMathsStatus = GetEnglishAndMathsStatus(response);

            if (englishAndMathsStatus == viewModel.EnglishAndMathsStatus)
            {
                return(new UpdateLearnerRecordResponseViewModel {
                    IsModified = false
                });
            }

            viewModel.HasLrsEnglishAndMaths = response.HasLrsEnglishAndMaths;
            var request   = _mapper.Map <UpdateLearnerRecordRequest>(viewModel, opt => { opt.Items["providerUkprn"] = providerUkprn; opt.Items["uln"] = response.Uln; });
            var isSuccess = await _internalApiClient.UpdateLearnerRecordAsync(request);

            return(new UpdateLearnerRecordResponseViewModel {
                ProfileId = response.ProfileId, Uln = response.Uln, Name = response.Name, IsModified = true, IsSuccess = isSuccess
            });
        }
 public override void Given()
 {
     ViewModel = new UpdateEnglishAndMathsQuestionViewModel();
     Controller.ModelState.AddModelError("EnglishAndMathsStatus", EnglishAndMathsQuestionContent.Validation_Select_Is_EnglishMaths_Achieved_Required_Message);
 }