public ActionResult Audit(int id, HistoryDataTablesModel param) { var source = DafRepository.QueryHistory(id); var filtered = source; if (!string.IsNullOrEmpty(param.FieldName)) { filtered = filtered.Where(f => f.FieldName.Contains(param.FieldName)); } if (param.fromDate.HasValue) { filtered = filtered.Where(f => f.UpdateDate >= param.fromDate); } if (param.toDate.HasValue) { filtered = filtered.Where(f => f.UpdateDate < param.toDate); } var ordered = filtered.OrderByField(param.sSortCol_0, param.sSortDir_0 == "asc"); var result = new jQueryDataTableResult { aaData = ordered.Skip(param.iDisplayStart).Take(param.iDisplayLength), iTotalDisplayRecords = filtered.Count(), iTotalRecords = source.Count(), sEcho = param.sEcho }; return(this.MyJsonResult(result)); }
public ActionResult Audit(int id, HistoryDataTablesModel param) { var source = from h in db.Histories where h.ReferenceId == id where h.TableName == "DAF" select new CC.Data.Models.HistoryRowModel { UpdateDate = h.UpdateDate, UpdatedBy = (h.User.FirstName + " " + h.User.LastName) ?? (h.User.UserName), FieldName = h.FieldName, OldValue = h.OldValue, NewValue = h.NewValue }; var filtered = source; if (!string.IsNullOrEmpty(param.FieldName)) { filtered = filtered.Where(f => f.FieldName.Contains(param.FieldName)); } if (param.fromDate.HasValue) { filtered = filtered.Where(f => f.UpdateDate >= param.fromDate); } if (param.toDate.HasValue) { filtered = filtered.Where(f => f.UpdateDate < param.toDate); } var ordered = filtered.OrderByField(param.sSortCol_0, param.sSortDir_0 == "asc"); var result = new jQueryDataTableResult { aaData = ordered.Skip(param.iDisplayStart).Take(param.iDisplayLength), iTotalDisplayRecords = filtered.Count(), iTotalRecords = source.Count(), sEcho = param.sEcho }; return(this.MyJsonResult(result)); }