public JsonResult GetAllEvent(jQueryDataTableParamModel param) { try { var allRecords = new List <Event>(); allRecords = MS.GetAllEvent(); List <Event> filteredRecords = null; if (!string.IsNullOrWhiteSpace(param.sSearch)) { allRecords = allRecords.Where(t => t.Id.ToString().Contains(param.sSearch.ToLower()) || t.Category.Name.ToLower().ToString().Contains(param.sSearch.ToLower()) || t.Title.ToLower().ToString().Contains(param.sSearch.ToLower()) || t.IsActive.ToString().ToLower().Contains(param.sSearch.ToLower())).OrderBy(t => t.Title).ToList(); filteredRecords = allRecords.Skip(param.iDisplayStart).Take(param.iDisplayLength).ToList(); } else { filteredRecords = allRecords .Skip(param.iDisplayStart) .Take(param.iDisplayLength).OrderBy(t => t.Title).ToList(); } int totalRecords = allRecords.Count(); var result = from c in filteredRecords select new[] { "", c.Id.ToString(), c.Title, c.Category.Name, c.Description, c.Image, Convert.ToDateTime(c.CreatedDate).ToString("dd/MM/yyyy HH:mm"), c.IsActive == true ? "Active" : "InActive", "" }; return(Json(new { sEcho = param.sEcho, iTotalRecords = totalRecords, iTotalDisplayRecords = totalRecords, aaData = result }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { CommonServices.ErrorLogging(ex); return(Json(new { sEcho = 1, iTotalRecords = 0, iTotalDisplayRecords = 0, aaData = new List <string[]> { } }, JsonRequestBehavior.AllowGet)); } }