public IHttpActionResult ListContents(string contentTypeId, string search = null, string sortColumn = null,
                                       bool?isDescending = null, int offset = 0, int limit = 100, ContentListShape?shape = null)
 {
     try {
         var rctx = ProtoCmsRuntimeContext.Current;
         var ct   = FindContentType(contentTypeId);
         CheckUserHasPermissionToViewContent(ct, rctx);
         var result = new ContentListApiResult(rctx, ct, search, sortColumn, isDescending,
                                               offset, limit, shape);
         return(JsonProto(result));
     } catch (HttpException hexc) {
         throw RestfulApiError(hexc);
     }
 }
 public IHttpActionResult ListContentsFiltered([FromBody] IDictionary <string, ContentTableFilterForm> filters,
                                               string contentTypeId, 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 ct   = FindContentType(contentTypeId);
             CheckUserHasPermissionToViewContent(ct, rctx);
             var finder    = ct.Finder();
             var filterOps = new List <ContentTableFilterOperation>();
             if (filters != null)
             {
                 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, ct);
                     if (filterOp != null)
                     {
                         filterOps.AddRange(filterOp);
                     }
                 }
                 finder = finder.TableFilter(filterOps);
             }
             var result = new ContentListApiResult(rctx, ct, search, sortColumn, isDescending,
                                                   offset, limit, shape, finder);
             return(JsonProto(result));
         }
         return(ResponseMessage(Request.CreateErrorResponse(
                                    HttpStatusCode.BadRequest, ModelState
                                    )));
     } catch (HttpException hexc) {
         throw RestfulApiError(hexc);
     }
 }