/// <summary> /// ค้นหา SearchHistory /// </summary> public JsonDataTableResult SearchAsync(FormCollection formcollection) { ReturnValues <TransactionViewModels> returnData = new ReturnValues <TransactionViewModels>(); DataTableJSON <TransactionViewModels> dataTable = new DataTableJSON <TransactionViewModels>(); DataTableProperty dataTableProperty = DataTableProperty.Get(formcollection); List <TransactionViewModels> data = new List <TransactionViewModels>(); try { int total = 0; int skip = dataTableProperty.StartRecord; int limit = dataTableProperty.EndRecord; string type_transaction = formcollection["type_transaction"].ToString(); string keyword = formcollection["keyword"].ToString(); string path = "http://122.155.202.166/api/controller/transaction_controller.php?type=" + type_transaction; if (!string.IsNullOrEmpty(keyword)) { path = "http://122.155.202.166/api/controller/transaction_controller.php?keyword=" + keyword + "&type=" + type_transaction; } JObject result = Request(keyword, path); if (result != null) { if (result["data"] != null) { data = JsonConvert.DeserializeObject <List <TransactionViewModels> >(result["data"].ToString()); total = data.Count; data = data.Skip(dataTableProperty.StartRecord).Take(dataTableProperty.EndRecord).ToList(); } } returnData = new ReturnValues <TransactionViewModels>(); returnData.Data = data; returnData.TotalRecord = total; returnData.Size = total; } catch (Exception ex) { notifyMsg(NotifyMsgType.Error, ex.Message); returnData = new ReturnValues <TransactionViewModels>(); returnData.Data = new List <TransactionViewModels>(); returnData.TotalRecord = 0; returnData.Size = 0; } dataTable.Echo = dataTableProperty.Echo; dataTable.TotalDisplayRecords = returnData.TotalRecord; dataTable.TotalRecords = returnData.TotalRecord; dataTable.Data = returnData.Data; return(new JsonDataTableResult(dataTable, JsonRequestBehavior.AllowGet)); }
public JsonResult GetAllUserListJSON(jQueryDataTableParamModel param) { string sortOrder = string.Empty; var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); if (sortColumnIndex == 0) { sortOrder = "UserId"; } else if (sortColumnIndex == 1) { sortOrder = "FullName"; } else if (sortColumnIndex == 2) { sortOrder = "Email"; } string search = "||"; //It's indicate blank filter if (!string.IsNullOrEmpty(param.sSearch)) { search = param.sSearch; } //var sortDirection = Request["sSortDir_0"]; // asc or desc var sortDirection = "desc"; int pageNo = 1; int recordPerPage = param.iDisplayLength; //Find page number from the logic if (param.iDisplayStart > 0) { pageNo = (param.iDisplayStart / recordPerPage) + 1; } DataTableProperty DataTableProperty = new DataTableProperty(); DataTableProperty.PageNo = pageNo; DataTableProperty.RecordPerPage = recordPerPage; DataTableProperty.Filter = search == "||" ? null : search; DataTableProperty.SortField = sortOrder; DataTableProperty.SortOrder = sortDirection; if (param.sSearch_1 != null) { DataTableProperty.FullName = param.sSearch_1; } if (param.sSearch_2 != null) { DataTableProperty.Email = param.sSearch_2; } var result1 = objAccessDB.GetUserList(DataTableProperty); dynamic result = ""; if (result1.EmployeeInfoList == null) { result = new List <EmployeeInfo>(); } else { result = from c in result1.EmployeeInfoList select new[] { c.UserId.ToString(), c.FullName.ToString(), c.Email.ToString(), c.ProfileImage.ToString() }; } return(Json(new { sEcho = param.sEcho, iTotalRecords = result1.totalNumberofRecord, iTotalDisplayRecords = result1.filteredRecord, aaData = result }, JsonRequestBehavior.AllowGet)); }
set => SetValue(DataTableProperty, value);