public JsonResult GetPeoplePaged(int offset, int limit, string search, string sort, string order) { var people = PeopleSource(); var model = new { total = people.Count(), rows = people.Skip((offset / limit) * limit).Take(limit), }; return Json(model, JsonRequestBehavior.AllowGet); }
public JsonResult GetPeopleSearch(int offset, int limit, string search, string sort, string order) { var people = PeopleSource().AsQueryable() .WhereIf(!string.IsNullOrEmpty(search), o => o.Email.Contains(search, StringComparison.InvariantCultureIgnoreCase) || o.FirstName.Contains(search, StringComparison.InvariantCultureIgnoreCase) || o.LastName.Contains(search, StringComparison.InvariantCultureIgnoreCase) || o.Location.Contains(search, StringComparison.InvariantCultureIgnoreCase)) .OrderBy(sort ?? "LastName", order) .ToList(); var model = new { total = people.Count(), rows = people.Skip((offset / limit) * limit).Take(limit), }; return Json(model, JsonRequestBehavior.AllowGet); }