Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }