示例#1
0
        /// <summary>
        /// Consutructor.
        /// </summary>
        public async Task <IEnumerable <BookDTO> > GetAllBooks(BooksFilters filters)
        {
            var applyFilter = _builderFilter.Empty;

            if (filters.FilterByTitle != null)
            {
                applyFilter = _builderFilter.Where(book => book.Title.Contains(filters.FilterByTitle));
            }
            var result = await _context.BookCollection.Find(applyFilter).SortBy(book => book.Authors).Skip(filters.PageSize * (filters.PageNumber - 1)).ToListAsync();

            return(_mapper.Map <IEnumerable <BookDTO> >(result));
        }
示例#2
0
 /// <summary>
 /// get books .
 /// </summary>
 public async Task <IEnumerable <BookDTO> > GetBooks(BooksFilters filters)
 {
     return(await _booksRepository.GetAllBooks(filters));
 }