// // GET: /Logger/GetLoggers/ public ActionResult GetLoggers(DataTableParamModel param) { var loggers = _db.Loggers.ToList(); var viewLoggers = loggers.Select(log => new LoggerTableModels() { LoggerId = Convert.ToString(log.LoggerId), Summery = log.Summery, Details = log.Details, FilePath = log.FilePath, Url = log.Url, LoggerTypeName = log.LoggerType == null ? null : Convert.ToString(log.LoggerType.LoggerTypeName) }); IEnumerable<LoggerTableModels> filteredLoggers; if (!string.IsNullOrEmpty(param.sSearch)) { filteredLoggers = viewLoggers.Where(pro => (pro.Summery ?? "").Contains(param.sSearch) || (pro.Details ?? "").Contains(param.sSearch) || (pro.LoggerTypeName ?? "").Contains(param.sSearch)).ToList(); } else { filteredLoggers = viewLoggers; } var viewOdjects = filteredLoggers.Skip(param.iDisplayStart).Take(param.iDisplayLength); var result = from logMdl in viewOdjects select new[] { logMdl.LoggerId, logMdl.Summery, logMdl.Details, logMdl.FilePath, logMdl.Url, logMdl.LoggerTypeName }; return Json(new { sEcho = param.sEcho, iTotalRecords = loggers.Count(), iTotalDisplayRecords = filteredLoggers.Count(), aaData = result }, JsonRequestBehavior.AllowGet); }
// for display datatable public ActionResult GetCategories(DataTableParamModel param) { var categories = _db.Categories.ToList(); var viewProducts = categories.Select(cat => new CategoryTableModels() { CategoryId = Convert.ToString(cat.CategoryId), Name = cat.Name }); IEnumerable<CategoryTableModels> filteredProducts; if (!string.IsNullOrEmpty(param.sSearch)) { filteredProducts = viewProducts.Where(cat => (cat.Name ?? "").Contains(param.sSearch)).ToList(); } else { filteredProducts = viewProducts; } var viewOdjects = filteredProducts.Skip(param.iDisplayStart).Take(param.iDisplayLength); var result = from catMdl in viewOdjects select new[] { catMdl.CategoryId, catMdl.Name }; return Json(new { sEcho = param.sEcho, iTotalRecords = categories.Count(), iTotalDisplayRecords = filteredProducts.Count(), aaData = result }, JsonRequestBehavior.AllowGet); }