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

            var searchResult = await _resultLoader.FindUlnResultsAsync(User.GetUkPrn(), model.SearchUln.ToLong());

            if (searchResult?.IsAllowed == true)
            {
                return(RedirectToRoute(searchResult.IsWithdrawn ? RouteConstants.ResultWithdrawnDetails : RouteConstants.ResultDetails, new { profileId = searchResult.RegistrationProfileId }));
            }
            else
            {
                await _cacheService.SetAsync(Constants.ResultsSearchCriteria, model.SearchUln);

                var ulnResultsNotfoundModel = new UlnResultsNotFoundViewModel {
                    Uln = model.SearchUln.ToString()
                };
                await _cacheService.SetAsync(string.Concat(CacheKey, Constants.SearchResultsUlnNotFound), ulnResultsNotfoundModel, CacheExpiryTime.XSmall);

                return(RedirectToRoute(RouteConstants.SearchResultsNotFound));
            }
        }
コード例 #2
0
        public override void Given()
        {
            SearchResultsViewModel = new SearchResultsViewModel {
                SearchUln = SearchUln
            };
            var mockResult = new UlnResultsNotFoundViewModel {
                IsAllowed = true, IsWithdrawn = false, Uln = SearchUln
            };

            ResultLoader.FindUlnResultsAsync(AoUkprn, SearchUln.ToLong()).Returns(mockResult);
        }
コード例 #3
0
 public async override Task When()
 {
     ActualResult = await Loader.FindUlnResultsAsync(Ukprn, Uln);
 }