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); }