public async Task <CQRSResult <List <BookGetDTO> > > Handle(BooksQuery request, CancellationToken cancellationToken) { var books = uow.BooksRepository.Get(); return(mapper.Map <List <BookGetDTO> >(books)); //return books.Select(x=> BookGetMap.ToDTO(x)).ToList(); }
private async Task <IEnumerable <Book> > GetBooksAsync(BooksQuery searchQuery) { var books = BooksQuery.GetBooksList(); var list = searchQuery.GetListNames(); books = FillBooksSelectedTimes(books, list); books.Sort((h1, h2) => h2.SelectedTimes.CompareTo(h1.SelectedTimes)); return(books); }
public async Task Invoke(HttpContext httpContext, ApplicationDbContext applicationContext) { var sent = false; if (httpContext.Request.Path.StartsWithSegments("/graph")) { using (var sr = new StreamReader(httpContext.Request.Body)) { var query = await sr.ReadToEndAsync(); if (!String.IsNullOrWhiteSpace(query)) { BooksQuery bq = new BooksQuery(applicationContext); var schema = new Schema { Query = bq }; if (httpContext.Request.Method == "OPTIONS") { var printedSchema = new SchemaPrinter(schema).Print(); await WriteResult(httpContext, printedSchema); sent = true; } else { var result = await new DocumentExecuter() .ExecuteAsync(options => { options.Schema = schema; options.Query = query; }).ConfigureAwait(false); CheckForErrors(result); await WriteResult(httpContext, result); sent = true; } } } } if (!sent) { await _next(httpContext); } }
public IEnumerable <Book> GetFilteredBooks(BooksQuery query) { var books = context.Books.AsQueryable(); if (query.EndYear.HasValue) { books = books.Where(book => book.Year <= query.EndYear); } if (query.StartYear.HasValue) { books = books.Where(book => book.Year >= query.StartYear); } if (!string.IsNullOrEmpty(query.Text)) { books = books.Where(book => book.Title.Contains(query.Text)); } return(books); }