public IActionResult GetBookOfaReview(int reviewId)
        {
            if (!_reviewRepository.ReviewExists(reviewId))
            {
                return(NotFound());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var book    = _reviewRepository.GetBookOfaReview(reviewId);
            var bookDto = new BookDto()
            {
                Id            = book.Id,
                BookPublished = book.BookPublished,
                Isbn          = book.Isbn,
                Title         = book.Title
            };

            return(Ok(bookDto));
        }
Example #2
0
        public IActionResult GetBook(string isbn)
        {
            if (!_bookRepository.BookExists(isbn))
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var book    = _bookRepository.GetBook(isbn);
            var bookDto = new BookDto()
            {
                Id            = book.Id,
                BookPublished = book.BookPublished,
                Isbn          = book.Isbn,
                Title         = book.Title
            };

            return(Ok(bookDto));
        }
        public IActionResult GetBook(int bookId)
        {
            if (!_bookRepository.BookExist(bookId))
            {
                return(NotFound());
            }

            var book = _bookRepository.GetBook(bookId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var bookDto = new BookDto()
            {
                Id    = book.Id,
                Title = book.Title,
                Isbn  = book.Isbn
            };

            return(Ok(bookDto));
        }
Example #4
0
        public IActionResult GetBook(string bookIsbn)
        {
            if (!_bookRepository.BookExists(bookIsbn))
            {
                return(NotFound());
            }

            var book = _bookRepository.GetBook(bookIsbn);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var bookDto = new BookDto
            {
                Id            = book.Id,
                Title         = book.Title,
                Isbn          = book.Isbn,
                DatePublished = book.DatePublished
            };

            return(Ok(bookDto));
        }
        public IActionResult GetBookById(int bookId)
        {
            if (!_bookRepo.isExists(bookId))
            {
                return(NotFound());
            }

            var book = _bookRepo.GetBookById(bookId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var bookDto = new BookDto
            {
                Id            = book.Id,
                Title         = book.Title,
                Isbn          = book.Isbn,
                DatePublished = book.DatePublished
            };

            return(Ok(bookDto));
        }
Example #6
0
        public IActionResult GetBookOfAReview(int reviewId)
        {
            if (!_reviewRepo.ReviewExists(reviewId))
            {
                return(NotFound());
            }

            var book = _reviewRepo.GetBookOfAReview(reviewId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var bookDto = new BookDto()
            {
                Id            = book.Id,
                Title         = book.Title,
                ISBN          = book.ISBN,
                DatePublished = book.DatePublished
            };

            return(Ok(bookDto));
        }