Beispiel #1
0
        public async Task <IActionResult> UpdateIndustryPlacementQuestionAsync(UpdateIndustryPlacementQuestionViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var response = await _trainingProviderLoader.ProcessIndustryPlacementQuestionUpdateAsync(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.IndustryPlacementUpdatedConfirmation), response, CacheExpiryTime.XSmall);

            return(RedirectToRoute(RouteConstants.IndustryPlacementUpdatedConfirmation));
        }
        public override void Given()
        {
            CreateMapper();
            ProviderUkprn         = 987654321;
            ProfileId             = 1;
            RegistrationPathwayId = 1;

            _expectedApiResult = new LearnerRecordDetails {
                ProfileId = ProfileId, Uln = 1234567890, Name = "Test User", IsLearnerRecordAdded = true, IndustryPlacementStatus = IndustryPlacementStatus.Completed
            };
            ViewModel = new UpdateIndustryPlacementQuestionViewModel {
                ProfileId = ProfileId, RegistrationPathwayId = RegistrationPathwayId, IndustryPlacementId = 0, IndustryPlacementStatus = IndustryPlacementStatus.NotCompleted
            };

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

            Loader = new TrainingProviderLoader(InternalApiClient, Mapper);
        }
        public override void Given()
        {
            ProviderUkprn         = 87945612;
            ProfileId             = 0;
            RegistrationPathwayId = 1;

            _expectedApiResult = null;
            ViewModel          = new UpdateIndustryPlacementQuestionViewModel {
                ProfileId = ProfileId, RegistrationPathwayId = RegistrationPathwayId, IndustryPlacementStatus = IndustryPlacementStatus.Completed
            };
            InternalApiClient.GetLearnerRecordDetailsAsync(ProviderUkprn, ProfileId, RegistrationPathwayId).Returns(_expectedApiResult);
        }
 public override void Given()
 {
     ProfileId  = 10;
     PathwayId  = 15;
     mockresult = new UpdateIndustryPlacementQuestionViewModel
     {
         ProfileId             = ProfileId,
         RegistrationPathwayId = PathwayId,
         IsLearnerRecordAdded  = false
     };
     TrainingProviderLoader.GetLearnerRecordDetailsAsync <UpdateIndustryPlacementQuestionViewModel>(ProviderUkprn, ProfileId, PathwayId).Returns(mockresult);
 }
        public override void Given()
        {
            _updateLearnerRecordResponse = null;

            UpdateIndustryPlacementQuestionViewModel = new UpdateIndustryPlacementQuestionViewModel
            {
                ProfileId = 1,
                IndustryPlacementStatus = IndustryPlacementStatus.Completed
            };

            TrainingProviderLoader.ProcessIndustryPlacementQuestionUpdateAsync(ProviderUkprn, UpdateIndustryPlacementQuestionViewModel).Returns(_updateLearnerRecordResponse);
        }
Beispiel #6
0
 public override void Given()
 {
     ProfileId  = 10;
     PathwayId  = 15;
     mockresult = new UpdateIndustryPlacementQuestionViewModel
     {
         ProfileId               = ProfileId,
         RegistrationPathwayId   = PathwayId,
         LearnerName             = "Test user",
         IsLearnerRecordAdded    = true,
         IndustryPlacementStatus = IndustryPlacementStatus.Completed
     };
     TrainingProviderLoader.GetLearnerRecordDetailsAsync <UpdateIndustryPlacementQuestionViewModel>(ProviderUkprn, ProfileId, PathwayId).Returns(mockresult);
 }
        public override void Given()
        {
            _updateLearnerRecordResponse = new UpdateLearnerRecordResponseViewModel
            {
                ProfileId  = 1,
                Uln        = 1234567890,
                Name       = "Test User",
                IsModified = true,
                IsSuccess  = false
            };

            UpdateIndustryPlacementQuestionViewModel = new UpdateIndustryPlacementQuestionViewModel
            {
                ProfileId               = 1,
                RegistrationPathwayId   = 1,
                IndustryPlacementStatus = IndustryPlacementStatus.Completed
            };

            TrainingProviderLoader.ProcessIndustryPlacementQuestionUpdateAsync(ProviderUkprn, UpdateIndustryPlacementQuestionViewModel).Returns(_updateLearnerRecordResponse);
        }
        public async Task <UpdateLearnerRecordResponseViewModel> ProcessIndustryPlacementQuestionUpdateAsync(long providerUkprn, UpdateIndustryPlacementQuestionViewModel viewModel)
        {
            var learnerRecordDetails = await _internalApiClient.GetLearnerRecordDetailsAsync(providerUkprn, viewModel.ProfileId, viewModel.RegistrationPathwayId);

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

            if (learnerRecordDetails.IndustryPlacementStatus == viewModel.IndustryPlacementStatus)
            {
                return(new UpdateLearnerRecordResponseViewModel {
                    IsModified = false
                });
            }

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

            return(new UpdateLearnerRecordResponseViewModel {
                ProfileId = learnerRecordDetails.ProfileId, Uln = learnerRecordDetails.Uln, Name = learnerRecordDetails.Name, IsModified = true, IsSuccess = isSuccess
            });
        }
Beispiel #9
0
 public override void Given()
 {
     UpdateIndustryPlacementQuestionViewModel = new UpdateIndustryPlacementQuestionViewModel();
     Controller.ModelState.AddModelError("IndustryPlacementStatus", IndustryPlacementQuestionContent.Validation_Select_Industry_Placement_Required_Message);
 }