protected async Task <BioQuery <TEntity> > ConfigureQueryAsync(BioQuery <TEntity> query, int page, Func <BioQuery <TEntity>, Task <BioQuery <TEntity> > >?configureQuery = null) { if (ControllerContext.HttpContext.Request.Query.ContainsKey("order")) { query.OrderByString(ControllerContext.HttpContext.Request.Query["order"]); } else { ApplyDefaultOrder(query); } if (page > 0) { Page = page; } else if (ControllerContext.HttpContext.Request.Query.ContainsKey("page")) { Page = int.Parse(ControllerContext.HttpContext.Request.Query["page"]); if (Page < 1) { Page = 1; } } query.ForSite(Site).Paginate(page, ItemsPerPage); if (configureQuery != null) { await configureQuery(query); } return(query); }
protected BioQuery <TEntity> ConfigureQuery(BioQuery <TEntity> query, int limit, int offset, string order, string filter) { if (!string.IsNullOrEmpty(filter) && filter != "null") { var mod4 = filter.Length % 4; if (mod4 > 0) { filter += new string('=', 4 - mod4); } var data = Convert.FromBase64String(filter); var decodedString = HttpUtility.UrlDecode(Encoding.UTF8.GetString(data)); if (!string.IsNullOrEmpty(decodedString)) { query = query.WhereByString(decodedString); } } if (!string.IsNullOrEmpty(order)) { query = query.OrderByString(order); } if (limit > 0) { query = query.Take(limit); } if (offset > 0) { query = query.Skip(offset); } return(query); }