Exemplo n.º 1
0
        public IEnumerable <Book> All(ResolveFieldContext <object> context)
        {
            var results = from books in _context.Books select books;

            if (context.HasArgument("name"))
            {
                var value = context.GetArgument <string>("name");
                results = results.Where(a => a.Name.Contains(value));
            }
            if (context.HasArgument("description"))
            {
                var value = context.GetArgument <string>("description");
                results = results.Where(a => a.Description.Contains(value));
            }
            if (context.HasArgument("price"))
            {
                var value = context.GetArgument <double>("price");
                results = results.Where(a => a.Price == value);
            }
            if (context.HasArgument("authorId"))
            {
                var value = context.GetArgument <long>("authorId");
                results = results.Where(a => a.AuthorId == value);
            }
            return(PaginatedList <Book> .Paginate(results, context));
        }
Exemplo n.º 2
0
        public IEnumerable <Author> All(ResolveFieldContext <object> context)
        {
            var results = from authors in _context.Authors select authors;

            if (context.HasArgument("name"))
            {
                var value = context.GetArgument <string>("name");
                results = results.Where(a => a.Name.Contains(value));
            }
            return(PaginatedList <Author> .Paginate(results, context));
        }