public ActionResult Get([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel) { var totalCount = _dbContext.GetTotalCount(); var orderBy = new Dictionary <string, string>(); var sortedColumns = requestModel.Columns.GetSortedColumns(); foreach (var column in sortedColumns) { orderBy[column.Data] = column.SortDirection.ToString(); } var queryResult = _dbContext.GetResults(requestModel.Search.Value, requestModel.Start, requestModel.Length, orderBy); return(Json(new DataTablesResponse(requestModel.Draw, queryResult.Data, queryResult.FilteredCount, queryResult.TotalCount), JsonRequestBehavior.AllowGet)); }
public IHttpActionResult Post([FromBody] DataTableRequest requestModel) { var orderBy = new Dictionary <string, string>(); var sortedColumns = requestModel.Order; foreach (var column in sortedColumns) { orderBy[requestModel.Columns[column.Column].Data] = column.Dir; } var queryResult = _dbContext.GetResults(requestModel.Search.Value, requestModel.Start, requestModel.Length, orderBy); var response = new CustomerSearchResponse { data = queryResult.Data, draw = requestModel.draw, recordsFiltered = queryResult.FilteredCount, recordsTotal = queryResult.TotalCount }; return(Json(response)); }