public JsonResult BindUsers([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, int RoleId = 0) { try { int totalRecord = 0; int filteredRecord = 0; PageParam pageParam = new PageParam(); pageParam.Offset = requestModel.Start; pageParam.Limit = requestModel.Length; string Search = requestModel.Search.Value; pageParam.SortBy = requestModel.Columns.ElementAt(requestModel.OrderColumn).Data; pageParam.SortDirection = requestModel.OrderDir.ToUpper() == "DESC" ? "Descending" : "Ascending"; var model = abstractUsersServices.UsersSelectAll(pageParam, Search, RoleId); totalRecord = (int)model.TotalRecords; filteredRecord = (int)model.TotalRecords; return(Json(new DataTablesResponse(requestModel.Draw, model.Values, filteredRecord, totalRecord), JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new object[] { Enums.MessageType.danger.GetHashCode(), Enums.MessageType.danger.ToString(), "Something Went Wrong" }, JsonRequestBehavior.AllowGet)); } }
public IList <SelectListItem> BindUserDropdown() { PageParam pageParam = new PageParam(); pageParam.Offset = 0; pageParam.Limit = 10000; var model = abstractUsersServices.UsersSelectAll(pageParam, ""); List <SelectListItem> items = new List <SelectListItem>(); foreach (var category in model.Values) { items.Add(new SelectListItem() { Text = category.Name.ToString(), Value = category.Id.ToString() }); } return(items); }