public async Task <IHttpActionResult> Get([FromUri] DocumentSearchOptions options) { var list = db.Documents.Select(s => s); list = SearchInternal(list, options); return(await Page(db.Documents, options.Page.Value)); }
public async Task <IHttpActionResult> Count([FromUri] DocumentSearchOptions options) { var list = db.Documents.Select(s => s); list = SearchInternal(list, options); var count = await list.CountAsync(); return(Ok(count)); }
private IQueryable <Document> SearchInternal(IQueryable <Document> list, DocumentSearchOptions opt) { if (!String.IsNullOrEmpty(opt.Search)) { list = Filter(list, opt.Search, opt.DeepSearch); } if (!String.IsNullOrEmpty(opt.Order)) { list = Sort(list, opt.Order, opt.Ascending.Value); } else { list = list.OrderByDescending(c => c.Id); } return(list); }