Ejemplo n.º 1
0
            public async Task <PagedList <Book> > Handle(GetBooksListQuery query)
            {
                var countSpec = new BooksByAuthorSpecification(query.AuthorId, query.SearchTitle);
                var listSpec  = new BooksByAuthorSpecification(query.AuthorId, query.SearchTitle,
                                                               query.PageNumber, query.PageSize);

                var count = await _unitOfWork.BookRepository.CountAsync(countSpec);

                var items = await _unitOfWork.BookRepository.ListAsync(listSpec);

                return(PagedList <Book> .Create(count, items.ToList(), query.PageNumber, query.PageSize));
            }
            public async Task <Book> Handle(GetBookQuery query)
            {
                var spec = new BooksByAuthorSpecification(query.AuthorId, query.BookId);

                return(await _unitOfWork.BookRepository.FirstOrDefaultAsync(spec));
            }