public ActionResult SimpleSearch(string name, int page, bool? async) { var realEstates = new Searcher().FilterByName(name).Result().ToList(); var range = realEstates.BoundedGetRange(MAX_PER_PAGE * (page - 1), MAX_PER_PAGE); if(async.HasValue && async.Value) { return PartialView("List", range); } int totalPages = (realEstates.Count + (MAX_PER_PAGE - 1)) / MAX_PER_PAGE; object routeValues = new { name }; return View("PagedList", new PageViewModel(range, new PaginationModel("Search", "Search", page, totalPages), routeValues)); }
public ActionResult AdvancedSearch(string name, string address, string city, decimal? minPrice, decimal? maxPrice, int? capacity, int page, bool? async, DateTime? fromDate, DateTime? toDate) { var realEstates = new Searcher().FilterByName(name). FilterByCity(city). FilterByAddress(address). FilterByAvailability(fromDate, toDate). FilterByPrice(minPrice.GetValueOrDefault(), maxPrice.GetValueOrDefault()). FilterByCapacity(capacity.GetValueOrDefault()). Result().ToList(); var range = realEstates.BoundedGetRange(MAX_PER_PAGE * (page - 1), MAX_PER_PAGE); if(async.HasValue && async.Value) { return PartialView("List", range); } int totalPages = (realEstates.Count + (MAX_PER_PAGE - 1)) / MAX_PER_PAGE; object routeValues = new { name, address, city, minPrice, maxPrice, capacity }; return View("PagedList", new PageViewModel(range, new PaginationModel("Advanced", "Search", page, totalPages), routeValues)); }