Пример #1
0
        private SearchedSchoolListViewModel GetSchoolViewModelList(dynamic response, string orderBy, int page)
        {
            var schoolListVm = new List <SchoolSearchResultViewModel>();
            var vm           = new SearchedSchoolListViewModel(schoolListVm, null, SearchTypes.SEARCH_BY_MAT, null, null, null, orderBy);

            if (response != null)
            {
                foreach (var result in response.Results)
                {
                    var schoolVm = new SchoolSearchResultViewModel(result);
                    schoolListVm.Add(schoolVm);
                }

                vm.SchoolComparisonList = _benchmarkBasketService.GetSchoolBenchmarkList();

                _filterBuilder.AddSchoolLevelFilters(response.Facets, Request.QueryString);
                _filterBuilder.AddOfstedRatingFilters(response.Facets, Request.QueryString);
                _filterBuilder.AddGenderFilters(response.Facets, Request.QueryString);
                var filters = _filterBuilder.GetResult();
                vm.Filters = filters;
                vm.FilterSelectionState = DetermineSelectionState(filters);

                vm.Pagination = new Pagination
                {
                    Start             = (SearchDefaults.TRUST_SCHOOLS_PER_PAGE * (page - 1)) + 1,
                    Total             = response.NumberOfResults,
                    PageLinksPerPage  = SearchDefaults.LINKS_PER_PAGE,
                    MaxResultsPerPage = SearchDefaults.TRUST_SCHOOLS_PER_PAGE,
                    PagedEntityType   = PagedEntityType.School
                };
            }

            return(vm);
        }
        protected SearchedSchoolListViewModel GetSearchedSchoolViewModelList(dynamic response, SchoolComparisonListModel schoolComparisonListModel, string orderBy, int page, string searchType, string nameKeyword, string locationKeyword, string laKeyword)
        {
            var schoolListVm = new List <SchoolSearchResultViewModel>();
            var vm           = new SearchedSchoolListViewModel(schoolListVm, null, searchType, nameKeyword, locationKeyword, laKeyword, orderBy);

            if (response != null)
            {
                foreach (var result in response.Results)
                {
                    var schoolVm = new SchoolSearchResultViewModel(result);
                    schoolListVm.Add(schoolVm);
                }

                vm.SchoolComparisonList = schoolComparisonListModel;

                _filterBuilder.AddSchoolLevelFilters(response.Facets, Request.QueryString);
                _filterBuilder.AddSchoolTypeFilters(response.Facets, Request.QueryString);
                _filterBuilder.AddOfstedRatingFilters(response.Facets, Request.QueryString);
                _filterBuilder.AddReligiousCharacterFilters(response.Facets, Request.QueryString);
                if (Request.QueryString?["searchType"] == SearchTypes.SEARCH_BY_LOCATION && Request.QueryString?["openOnly"] != "true")
                {
                    _filterBuilder.AddStatusFilters(response.Facets, Request.QueryString);
                }
                var filters = _filterBuilder.GetResult();
                vm.Filters = filters;
                vm.FilterSelectionState = DetermineSelectionState(filters);

                vm.Pagination = new Pagination
                {
                    Start             = (SearchDefaults.RESULTS_PER_PAGE * (page - 1)) + 1,
                    Total             = response.NumberOfResults,
                    PageLinksPerPage  = SearchDefaults.LINKS_PER_PAGE,
                    MaxResultsPerPage = SearchDefaults.RESULTS_PER_PAGE,
                    PagedEntityType   = PagedEntityType.School
                };
            }

            return(vm);
        }