Esempio n. 1
0
        private SchoolListViewModel GetSchoolViewModelList(dynamic response, string orderBy, int page)
        {
            var schoolListVm = new List <SchoolViewModel>();
            var vm           = new SchoolListViewModel(schoolListVm, null, orderBy);

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

                vm.SchoolComparisonList = base.ExtractSchoolComparisonListFromCookie();

                var filters = _filterBuilder.ConstructTrustSchoolSearchFilters(Request.QueryString, response.Facets);
                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
                };
            }

            return(vm);
        }