public ActionResult ListByRegion(decimal lat, decimal lng, decimal latDelta, decimal lngDelta, string layerId, string format, int? page, int? page_size) { decimal latMin = lat - latDelta; decimal latMax = lat + latDelta; decimal lngMin = lng - lngDelta; decimal lngMax = lng + lngDelta; IQueryable<PointDataSummary> iq = PointDataSummary.All().Where( c => (c.Latitude >= latMin && c.Latitude <= latMax) && (c.Longitude >= lngMin && c.Longitude <= lngMax) ).OrderByDescending(c => c.CreatedOn); if (!String.IsNullOrEmpty(layerId)) { iq = iq.Where( c => c.LayerId == layerId ); } if (page == null || page_size == null) { page = 0; page_size = MAX_ITEMS_PER_PAGE; } PagedList<PointDataSummary> pl = new PagedList<PointDataSummary>(iq, page.Value, page_size.Value); iq = pl.AsQueryable(); if (iq == null) { return Json(new List<PointDataSummary> { }, JsonRequestBehavior.AllowGet); } else { return Json(iq.ToList(), JsonRequestBehavior.AllowGet); } }
public ActionResult List(string format, int? page, int? page_size) { IQueryable<PointDataSummary> iq = PointDataSummary.All() .OrderByDescending(c => c.CreatedOn); if (page == null || page_size == null) { page = 0; page_size = MAX_ITEMS_PER_PAGE; } PagedList<PointDataSummary> pl = new PagedList<PointDataSummary>(iq, page.Value, page_size.Value); iq = pl.AsQueryable(); if (iq == null) { return Json(new List<PointDataSummary> { }, JsonRequestBehavior.AllowGet); } else { return Json(iq.ToList(), JsonRequestBehavior.AllowGet); } }