public async Task <IActionResult> FindProviderAsync(FindProviderViewModel viewModel)
        {
            if (!await FindProviderViewModelValidated(viewModel))
            {
                return(View(viewModel));
            }

            var hasAnyTlevelSetup = await _providerLoader.HasAnyTlevelSetupForProviderAsync(User.GetUkPrn(), viewModel.SelectedProviderId);

            return(RedirectToRoute(hasAnyTlevelSetup ? RouteConstants.ProviderTlevels : RouteConstants.SelectProviderTlevels, new { providerId = viewModel.SelectedProviderId }));
        }
        public async Task <IActionResult> FindProviderAsync(bool isback = false)
        {
            var yourProvidersExists = await _providerLoader.IsAnyProviderSetupCompletedAsync(User.GetUkPrn());

            var viewModel = new FindProviderViewModel {
                ShowViewProvidersLink = yourProvidersExists
            };

            viewModel.Search = isback ? TempData.Get <string>(Constants.FindProviderSearchCriteria) : null;
            return(View(viewModel));
        }
Exemple #3
0
        public override void Setup()
        {
            HttpContextAccessor = Substitute.For <IHttpContextAccessor>();
            ProviderLoader      = Substitute.For <IProviderLoader>();
            Logger     = Substitute.For <ILogger <ProviderController> >();
            Controller = new ProviderController(ProviderLoader, Logger);

            // Default value
            ViewModel = new FindProviderViewModel {
                Search = ProviderName, SelectedProviderId = SelectedProviderId
            };
            var httpContext = new ClaimsIdentityBuilder <ProviderController>(Controller)
                              .Add(CustomClaimTypes.Ukprn, Ukprn.ToString())
                              .Build()
                              .HttpContext;

            HttpContextAccessor.HttpContext.Returns(httpContext);
        }
Exemple #4
0
        public Task <ActionResult> Invitation()
        {
            var userRef       = Guid.NewGuid();
            var correlationId = Guid.NewGuid();
            var ukprn         = 12345678;
            var accountId     = 1;

            InvitationAccountProviderRouteValues = new InvitationAccountProviderRouteValues {
                AccountId     = accountId,
                CorrelationId = correlationId,
                UserRef       = userRef
            };

            GetInvitationByIdQueryResult = new GetInvitationByIdQueryResult(new InvitationDto {
                EmployerEmail        = "*****@*****.**",
                EmployerFirstName    = "John",
                EmployerLastName     = "Smtih",
                EmployerOrganisation = "ESFA",
                Ukprn  = ukprn,
                Status = 0
            });

            AddAccountProviderViewModel = new AddAccountProviderViewModel {
                AccountId = accountId,
                UserRef   = userRef,
                Ukprn     = ukprn
            };

            FindProviderViewModel = new FindProviderViewModel {
                //AccountId = accountId,
                Ukprn = ukprn.ToString()
            };

            AccountProviderId = 2;

            FindProvidersQueryResult = new FindProviderToAddQueryResult(12345678, null);

            Mediator.Setup(m => m.Send(It.Is <FindProviderToAddQuery>(q => q.AccountId == 1 && q.Ukprn == 12345678), CancellationToken.None)).ReturnsAsync(FindProvidersQueryResult);
            Mediator.Setup(m => m.Send(It.IsAny <AddAccountProviderCommand>(), CancellationToken.None)).ReturnsAsync(AccountProviderId);
            Mediator.Setup(m => m.Send(It.IsAny <GetInvitationByIdQuery>(), CancellationToken.None)).ReturnsAsync(GetInvitationByIdQueryResult);

            return(AccountProvidersController.Invitation(InvitationAccountProviderRouteValues));
        }
        private async Task <bool> FindProviderViewModelValidated(FindProviderViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(false);
            }

            if (viewModel.SelectedProviderId == 0)
            {
                var providerData = await _providerLoader.GetProviderLookupDataAsync(viewModel.Search, isExactMatch : true);

                if (providerData == null || providerData.Count() != 1)
                {
                    _logger.LogInformation(LogEvent.ProviersNotFound,
                                           $"No provider found. Method: GetProviderLookupDataAsync(Search: {viewModel.Search}, isExactMatch: {true}), User: {User.GetUserEmail()}");
                    ModelState.AddModelError("Search", Web.Content.Provider.FindProvider.ProviderName_NotValid_Validation_Message);
                    return(false);
                }

                viewModel.SelectedProviderId = providerData.First().Id;
            }

            return(true);
        }
Exemple #6
0
 public override void Given()
 {
     ViewModel = new FindProviderViewModel();
     Controller.ModelState.AddModelError("Search", "Please enter the provider name");
 }