public async Task <IActionResult> AddCoreAssessmentEntryAsync(AddAssessmentEntryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (!model.IsOpted.Value)
            {
                return(RedirectToRoute(RouteConstants.AssessmentDetails, new { model.ProfileId }));
            }

            model.ComponentType = ComponentType.Core;
            var response = await _assessmentLoader.AddAssessmentEntryAsync(User.GetUkPrn(), model);

            if (!response.IsSuccess)
            {
                _logger.LogWarning(LogEvent.AddCoreAssessmentEntryFailed, $"Unable to add core assessment for ProfileId: {model.ProfileId}. Method: AddAssessmentEntryAsync, Ukprn: {User.GetUkPrn()}, User: {User.GetUserEmail()}");
                return(RedirectToRoute(RouteConstants.Error, new { StatusCode = 500 }));
            }

            await _cacheService.SetAsync(string.Concat(CacheKey, Constants.AddAssessmentEntryConfirmationViewModel),
                                         new AddAssessmentEntryConfirmationViewModel { ProfileId = model.ProfileId, Uln = response.Uln },
                                         CacheExpiryTime.XSmall);

            return(RedirectToRoute(RouteConstants.AssessmentEntryAddedConfirmation));
        }
 public override void Given()
 {
     ViewModel = new AddAssessmentEntryViewModel
     {
         ProfileId            = 1,
         AssessmentSeriesId   = 11,
         AssessmentSeriesName = "Summer 2021",
         IsOpted = false
     };
 }
Beispiel #3
0
        public override void Given()
        {
            mockresult = new AddAssessmentEntryViewModel
            {
                ProfileId            = 1,
                AssessmentSeriesId   = 11,
                AssessmentSeriesName = "Summer 2021",
            };

            AssessmentLoader.GetAvailableAssessmentSeriesAsync(AoUkprn, ProfileId, ComponentType.Core).Returns(mockresult);
        }
Beispiel #4
0
        public override void Given()
        {
            ViewModel = new AddAssessmentEntryViewModel
            {
                ProfileId            = 1,
                AssessmentSeriesId   = 11,
                AssessmentSeriesName = "Summer 2021",
                IsOpted = null
            };

            Controller.ModelState.AddModelError(nameof(AddAssessmentEntryViewModel.IsOpted), AssessmentContent.AddCoreAssessmentEntry.Select_Option_To_Add_Validation_Text);
        }
        public override void Given()
        {
            ViewModel = new AddAssessmentEntryViewModel
            {
                ProfileId            = 1,
                AssessmentSeriesId   = 11,
                AssessmentSeriesName = "Summer 2021",
                IsOpted = true
            };

            AddAssessmentEntryResponse = new AddAssessmentEntryResponse {
                IsSuccess = false
            };
            AssessmentLoader.AddAssessmentEntryAsync(AoUkprn, ViewModel).Returns(AddAssessmentEntryResponse);
        }
        public override void Given()
        {
            ViewModel = new AddAssessmentEntryViewModel
            {
                ProfileId          = ProfileId,
                AssessmentSeriesId = 1,
                ComponentType      = Common.Enum.ComponentType.Core,
            };

            ExpectedApiResult = new AddAssessmentEntryResponse {
                IsSuccess = true, Uln = 1234567890
            };
            InternalApiClient
            .AddAssessmentEntryAsync(Arg.Is <AddAssessmentEntryRequest>(
                                         x => x.ProfileId == ViewModel.ProfileId &&
                                         x.AoUkprn == AoUkprn &&
                                         x.ComponentType == Common.Enum.ComponentType.Core &&
                                         x.AssessmentSeriesId == ViewModel.AssessmentSeriesId))
            .Returns(ExpectedApiResult);
        }
Beispiel #7
0
 public async override Task When()
 {
     ActualResult = await Loader.GetAvailableAssessmentSeriesAsync(AoUkprn, ProfileId, componentType);
 }
        public async Task <AddAssessmentEntryResponse> AddAssessmentEntryAsync(long aoUkprn, AddAssessmentEntryViewModel viewModel)
        {
            var request = _mapper.Map <AddAssessmentEntryRequest>(viewModel, opt => opt.Items["aoUkprn"] = aoUkprn);

            return(await _internalApiClient.AddAssessmentEntryAsync(request));
        }