コード例 #1
0
        public void FindYourCentreViewModel_without_centreid_should_have_default_Url()
        {
            // When
            var model = new FindYourCentreViewModel();

            // Then
            model.Url.Should().BeEquivalentTo(defaultUrl);
        }
コード例 #2
0
        public void FindYourCentreViewModel_with_centreid_should_have_centreid_added_to_Url()
        {
            // Given
            var centreId = "5";

            // When
            var model = new FindYourCentreViewModel(centreId);

            // Then
            model.Url.Should().BeEquivalentTo(defaultUrl + "&centreid=" + centreId);
        }
コード例 #3
0
        public async Task <IActionResult> Index(
            int page                    = 1,
            string?searchString         = null,
            string?existingFilterString = null,
            string?newFilterToAdd       = null,
            bool clearFilters           = false,
            int?itemsPerPage            = null
            )
        {
            if (!await featureManager.IsEnabledAsync(FeatureFlags.RefactoredFindYourCentrePage))
            {
                var model = new FindYourCentreViewModel(configuration);

                return(View("Index", model));
            }

            existingFilterString = FilteringHelper.GetFilterString(
                existingFilterString,
                newFilterToAdd,
                clearFilters,
                Request,
                FindCentreFilterCookieName
                );

            var centreSummaries = centresService.GetAllCentreSummariesForFindCentre();
            var regions         = regionDataService.GetRegionsAlphabetical();

            var availableFilters = FindYourCentreViewModelFilterOptions
                                   .GetFindCentreFilterModels(regions).ToList();

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString, searchMatchCutoff: 90),
                null,
                new FilterOptions(
                    existingFilterString,
                    availableFilters
                    ),
                new PaginationOptions(page, itemsPerPage)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                centreSummaries,
                searchSortPaginationOptions
                );

            var refactoredModel = new RefactoredFindYourCentreViewModel(
                result,
                availableFilters
                );

            Response.UpdateFilterCookie(FindCentreFilterCookieName, result.FilterString);

            return(View("RefactoredFindYourCentre", refactoredModel));
        }