public JsonResult GetKeywordLog(PagingOptions options, long CampID) { //paging parameter var start = options.Start; var length = options.Length; //sorting parameter //var sortColumn = options.ColumnName; //var sortColumnDir = options.Direction ? "ascending" : "descending"; //filter parameter //var searchValue = Request.Form.GetValues("search[value]").FirstOrDefault(); int pageSize = length; int skip = start; int recordsTotal = 0; var keylog = optimizeData.GetKeywordLogData(CampID, SessionData.UserID); //Database query var v = from a in keylog orderby DateTime.Parse(a.ModifiedOn) descending select a; //if (!string.IsNullOrEmpty(searchValue)) //{ // v = v.Where(a => // a.CampaignName.Contains(searchValue) // ); //} //sort //if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir))) //{ // //for make sort simpler we will add Syste.Linq.Dynamic reference // v = v.OrderBy(sortColumn + " " + sortColumnDir); //} recordsTotal = v.Count(); keylog = v.Skip(skip).Take(pageSize).ToList(); return(Json(new { recordsTotal = recordsTotal, data = keylog })); }
public JsonResult GetKeywordLog(PagingOptions options, long CampID, Int32 FilterArg) { //paging parameter var start = options.Start; var length = options.Length; //sorting parameter var sortColumn = options.ColumnName; var sortColumnDir = options.Direction ? "descending" : "ascending"; //filter parameter var searchValue = options.SearchName; int pageSize = length; int skip = start; int recordsTotal = 0; var keylog = optimizeData.GetKeywordLogData(CampID, SessionData.UserID); // all data taken //Database query var v = from a in keylog select a; if (FilterArg == 0) { recordsTotal = v.Count(); keylog = v.Skip(skip).Take(pageSize).ToList(); } else { if (!string.IsNullOrEmpty(searchValue)) { v = v.Where(a => a.KeywordName.ToLower().Contains(searchValue.ToLower())); } recordsTotal = v.Count(); keylog = v.Skip(skip).Take(pageSize).ToList(); } return(Json(new { recordsTotal = recordsTotal, data = keylog })); }