public async Task <ActionResult <BookDTO> > GetBookById(int id)
        {
            var spec = new BooksWithCategoriesAndAuthorsSpecification(id);
            var book = await _bookRepository.GetEntityWithSpec(spec);

            if (book == null)
            {
                return(NotFound(new ApiResponse(404)));
            }

            return(_mapper.Map <Book, BookDTO>(book));
        }
        public async Task <ActionResult <IEnumerable <BookDTO> > > GetBooks([FromQuery] BookSpecificationParams bookParams)
        {
            var spec = new BooksWithCategoriesAndAuthorsSpecification(bookParams);

            // get any overall count of items (after filtering has been applied)
            var countSpec  = new BooksWithFiltersForCountSpecification(bookParams);
            var totalItems = await _bookRepository.CountAsync(countSpec);

            // add pagination response headers to help client applications
            _httpContextAccessor.HttpContext.AddPaginationResponseHeaders(totalItems, bookParams.PageSize, bookParams.PageIndex);

            var books = await _bookRepository.ListAsync(spec);

            return(Ok(_mapper.Map <IEnumerable <Book>, IEnumerable <BookDTO> >(books)));
        }