public ActionResult AjaxHandler(JQueryDataTableParam param) { BusinessLayer <Equipment> bl = new BusinessLayer <Equipment>(new CapaNavDocDal()); BusinessLayer <MaintenanceData> mbl = new BusinessLayer <MaintenanceData>(new CapaNavDocDal()); BusinessLayer <ActivityField> afbl = new BusinessLayer <ActivityField>(new CapaNavDocDal()); List <EquipmentDetailsViewModel> model = new List <EquipmentDetailsViewModel>(bl.GetList().Select(e => (EquipmentDetailsViewModel)e.ToModel(new EquipmentDetailsViewModel()))); model = TableDataAdapter.Search(model, param); model = TableDataAdapter.SortList(model, param); model = TableDataAdapter.PageList(model, param); string[][] data = model.Select(m => new[] { m.Id.ToString(), m.PartNumber, m.Manufacturer, m.Name, m.Type, m.Ata.ToString(), m.ActivityFieldId.ToInt32() == 0 ? "" : afbl.Get(m.ActivityFieldId.ToInt32()).Description, m.MechanicsGroup, m.MaintenanceDataId.ToInt32() == 0 ? "" : mbl.Get(m.MaintenanceDataId.ToInt32()).Name, m.MonitoringDate, m.MaintenanceDataId }).ToArray(); return(Json(new { param.sEcho, iTotalRecords = model.Count, iTotalDisplayRecords = param.iDisplayLength, aaData = data }, JsonRequestBehavior.AllowGet)); }
public static List <T> Search <T>(List <T> list, JQueryDataTableParam param) { List <T> result = new List <T>(); List <PropertyInfo> properties = typeof(T).GetProperties().Where(p => p.PropertyType == typeof(string)).ToList(); if (properties.Count == 0 || string.IsNullOrEmpty(param.sSearch)) { return(list); } foreach (T t in list) { foreach (PropertyInfo property in properties) { string value = ((string)property.GetValue(t)); if (string.IsNullOrEmpty(value)) { continue; } if (!value.ToUpper().Contains(param.sSearch.ToUpper())) { continue; } result.Add(t); break; } } return(result); }
public static List <T> SortList <T>(List <T> list, JQueryDataTableParam param) { IEnumerable <PropertyInfo> properties = typeof(T).GetProperties().Where(p => p.GetCustomAttributes(typeof(ColumnAttribute)).Count() == 1); PropertyInfo property = properties.FirstOrDefault(p => ((ColumnAttribute[])p.GetCustomAttributes(typeof(ColumnAttribute)))[0].Column == param.iSortCol_0); if (property == null) { return(list); } Type t = list[0].GetType(); return(param.sSortDir_0 == "asc" ? list.OrderBy(u => t.InvokeMember(property.Name, BindingFlags.GetProperty, null, u, null)).ToList() : list.OrderByDescending(u => t.InvokeMember(property.Name, BindingFlags.GetProperty, null, u, null)).ToList()); }
public ActionResult AjaxHandler(JQueryDataTableParam param) { BusinessLayer <User> bl = new BusinessLayer <User>(new CapaNavDocDal()); List <UserDetailsViewModel> model = new List <UserDetailsViewModel>(bl.GetList().Select(u => (UserDetailsViewModel)u.ToModel(new UserDetailsViewModel()))); model = TableDataAdapter.Search(model, param); model = TableDataAdapter.SortList(model, param); model = TableDataAdapter.PageList(model, param); string[][] data = model.Select(m => new[] { m.Id.ToString(), m.FirstName, m.LastName, m.UserName, m.Password }).ToArray(); return(Json(new { param.sEcho, iTotalRecords = model.Count, iTotalDisplayRecords = param.iDisplayLength, aaData = data }, JsonRequestBehavior.AllowGet)); }
public ActionResult AjaxHandler(JQueryDataTableParam param) { BusinessLayer <MaintenanceData> bl = new BusinessLayer <MaintenanceData>(new CapaNavDocDal()); List <MaintenanceDataDetailsViewModel> model = new List <MaintenanceDataDetailsViewModel>(bl.GetList().Select(d => (MaintenanceDataDetailsViewModel)d.ToModel(new MaintenanceDataDetailsViewModel()))); model = TableDataAdapter.Search(model, param); model = TableDataAdapter.SortList(model, param); model = TableDataAdapter.PageList(model, param); string[][] data = model.Select(m => new[] { m.Id, m.Type, m.Sender, m.DocumentReference, m.DocumentPartNumber, m.Review, m.Date, m.Name, m.OnCertificate, m.MonitoringDate, bl.Get(m.Id.ToInt32()).Document == null ? null : "" }).ToArray(); return(Json(new { param.sEcho, iTotalRecords = model.Count, iTotalDisplayRecords = param.iDisplayLength, aaData = data }, JsonRequestBehavior.AllowGet)); }
public ActionResult AjaxHandler(JQueryDataTableParam param) { BusinessLayer <ActivityField> bl = new BusinessLayer <ActivityField>(new CapaNavDocDal()); List <ActivityFieldDetailsViewModel> model = new List <ActivityFieldDetailsViewModel>(bl.GetList().Select(a => (ActivityFieldDetailsViewModel)a.ToModel(new ActivityFieldDetailsViewModel()))); model = TableDataAdapter.Search(model, param); model = TableDataAdapter.SortList(model, param); model = TableDataAdapter.PageList(model, param); string[][] data = model.Select(m => new[] { m.Id.ToString(), m.Description }).ToArray(); return(Json(new { param.sEcho, iTotalRecords = model.Count, iTotalDisplayRecords = param.iDisplayLength, aaData = data }, JsonRequestBehavior.AllowGet)); }
public static List <T> PageList <T>(List <T> list, JQueryDataTableParam param) { return(list.Skip(param.iDisplayStart).Take(param.iDisplayLength).ToList()); }