private static IEnumerable<string[]> GetJsonFromPage(SalesPage page) { return from c in page.Displayed select new[] { c.Id.ToString(), c.Date.ToShortDateString(), c.Goods.Name, c.Manager.SecondName, c.Client.FullName, c.SellingPrice.ToString() }; }
public JsonResult SalesData(JQueryDataTableParamViewModel table, SaleFilterViewModel filter) { if (ModelState.IsValid) { var page = new SalesPage(); try { var filterModel = GetSalesFilter(filter); var sortOpt = GetSalesSortingOptions(); page = BO.SaleService.GetPage(filterModel, sortOpt, table.iDisplayStart, table.iDisplayLength); } catch (Exception e) { Log.Error(e); } return Json(new { sEcho = table.sEcho, iTotalRecords = page.TotalRecords, iTotalDisplayRecords = page.TotalDisplayRecords, aaData = GetJsonFromPage(page) }, JsonRequestBehavior.AllowGet); } return Json(new { success = false, message = "Invalid params" }); }