public IHttpActionResult ListData(string datumTypeId, string search = null, string sortColumn = null, bool?isDescending = null, int offset = 0, int limit = 100, ContentListShape?shape = null) { try { var rctx = ProtoCmsRuntimeContext.Current; var dt = FindDatumType(datumTypeId); CheckUserHasPermissionToViewDatum(dt, rctx); var result = new DatumListApiResult(rctx, dt, search, sortColumn, isDescending, offset, limit, shape); return(JsonProto(result)); } catch (HttpException hexc) { throw RestfulApiError(hexc); } }
public IHttpActionResult ListDataFiltered([FromBody] IDictionary <string, ContentTableFilterForm> filters, string datumTypeId, string search = null, string sortColumn = null, bool?isDescending = null, int offset = 0, int limit = 100, ContentListShape?shape = null) { try { if (ModelState.IsValid) { var rctx = ProtoCmsRuntimeContext.Current; var dt = FindDatumType(datumTypeId); CheckUserHasPermissionToViewDatum(dt, rctx); var finder = dt.FinderBase(); if (filters != null) { var filterOps = new List <ContentTableFilterOperation>(); foreach (var fkv in filters) { if (!fkv.Value.__IsFilterEnabled) { continue; } var filterHandler = finder.TableFilterHandlers.FirstOrDefault(x => x.Id == fkv.Key); var filterOp = filterHandler?.SetupFilteringOperations(fkv.Value, dt.ModelType); if (filterOp != null) { filterOps.AddRange(filterOp); } } finder = finder.TableFilterBase(filterOps); } var result = new DatumListApiResult(rctx, dt, search, sortColumn, isDescending, offset, limit, shape, finder); return(JsonProto(result)); } return(ResponseMessage(Request.CreateErrorResponse( HttpStatusCode.BadRequest, ModelState ))); } catch (HttpException hexc) { throw RestfulApiError(hexc); } }