public IActionResult GetBookById(int bookId)
        {
            var ComplBViewModel = new CompleteBookViewModel
            {
                AuthorCountry  = new Dictionary <AuthorDto, CountryDto>(),
                ReviewReviewer = new Dictionary <ReviewDto, ReviewerDto>()
            };

            var book = _bookRepository.GetBookById(bookId);

            if (book == null)
            {
                ModelState.AddModelError("", "Some kind of error during getting a book");
                book = new BookDto();
            }

            var categories = _categoryRepository.GetAllCategoriesOfABook(bookId);

            if (categories.Count() <= 0)
            {
                ModelState.AddModelError("", "Some kind of error during getting categories");
            }

            var rating = _bookRepository.GetBookRating(bookId);

            ComplBViewModel.Book       = book;
            ComplBViewModel.Categories = categories;
            ComplBViewModel.Rating     = rating;

            var authors = _authorRepository.GetAuthorsOfABook(bookId);

            if (authors.Count() <= 0)
            {
                ModelState.AddModelError("", "Some kind of error during getting categories");
            }
            foreach (var author in authors)
            {
                var country = _countryRepository.GetCountryOfAnAuthor(author.Id);
                ComplBViewModel.AuthorCountry.Add(author, country);
            }

            var reviews = _reviewRepository.GetReviewsOfABook(bookId);

            if (reviews.Count() <= 0)
            {
                ViewBag.ReviewsMessage = "There are no reviews yet";
            }
            foreach (var review in reviews)
            {
                var reviewer = _reviewerRepository.GetReviewerOfAReview(review.Id);
                ComplBViewModel.ReviewReviewer.Add(review, reviewer);
            }

            if (!ModelState.IsValid)
            {
                ViewBag.BookMessage = "Teher was an error retrieving a complete book record";
            }

            return(View(ComplBViewModel));
        }
        public IActionResult GetReviewById(int reviewId)
        {
            var review = _reviewRepository.GetReviewById(reviewId);

            if (review == null)
            {
                ModelState.AddModelError("", "Some kind of error getting review");
                ViewBag.Message = $"There was a problem retrieving review from the " +
                                  $"database or no review with id {reviewId}  exists";
                review = new ReviewDto();
            }

            var reviewer = _reviewerRepository.GetReviewerOfAReview(reviewId);

            if (reviewer == null)
            {
                ModelState.AddModelError("", "Some kind of error getting reviewer");
                ViewBag.Message += $"There was a problem retrieving reviewer from the database " +
                                   $"or no reviewer for the review id {reviewId} exist";
                reviewer = new ReviewerDto();
            }

            var book = _reviewRepository.GetBookOfAReview(reviewId);

            if (book == null)
            {
                ModelState.AddModelError("", "Some kind of error getting book");
                ViewBag.Message += $"There was a problem retrieving book from the database " +
                                   $"or no book for the review id {reviewId} exist";
                book = new BookDto();
            }

            var reviewReviewerBookViewModel = new ReviewReviewerBookViewModel
            {
                Review   = review,
                Reviewer = reviewer,
                Book     = book
            };

            ViewBag.SuccessMessage = TempData["SuccessMessage"];
            return(View(reviewReviewerBookViewModel));
        }
        public IActionResult GetReviewById(int reviewid)
        {
            var review = _reviewRepositoryGUI.GetReviewByID(reviewid);

            if (review == null)
            {
                ModelState.AddModelError(string.Empty, "Some kind of error while Getting the review");

                ViewBag.reviewMsg = $"There was an error while getting the review from the database or Review of {reviewid} does not exist";

                review = new ReviewDto();
            }

            var reviewer = _reviewerRepositoryGUI.GetReviewerOfAReview(reviewid);

            if (reviewer == null)
            {
                ModelState.AddModelError(string.Empty, "Some kind of error while Getting the reviewer");

                ViewBag.reviewMsg += $"There was an error while getting the reviewer from the database or Review of {reviewid} does not exist";

                reviewer = new ReviewerDto();
            }

            //            var book= _bookRepositoryGUI.get

            var book = _reviewRepositoryGUI.GetBookOfAReview(reviewid);

            if (book == null)
            {
                ModelState.AddModelError(string.Empty, "Some kind of error while Getting the reviewer");

                ViewBag.reviewMsg += $"There was an error while getting the reviewer from the database or Review of {reviewid} does not exist";

                book = new BookDto();
            }

            var reviewReviewerBook = new ReviewReviewerBookViewModel()
            {
                Book     = book,
                Review   = review,
                Reviewer = reviewer
            };

            return
                (View(reviewReviewerBook));
        }
        public IActionResult GetReviewById(int reviewId)
        {
            var review = _reviewRepository.GetReviewById(reviewId);

            if (review == null)
            {
                ModelState.AddModelError("", "Error getting a review");
                ViewBag.Review = $"There was a problem retrieving review with Id={reviewId} " +
                                 $"from the database or no review with this id exists";
                review = new ReviewDto();
            }

            var reviewer = _reviewerRepository.GetReviewerOfAReview(reviewId);

            if (reviewer == null)
            {
                ModelState.AddModelError("", "Error getting a reviewer");
                ViewBag.Reviewer = $"There was a problem retrieving reviewer of review Id={reviewId} " +
                                   $"from the database or no reviewer exists";
                reviewer = new ReviewerDto();
            }

            var book = _reviewRepository.GetBookOfAReview(reviewId);

            if (book == null)
            {
                ModelState.AddModelError("", "Error getting a book");
                ViewBag.Book = $"There was a problem retrieving book of review Id={reviewId} " +
                               $"from the database or no book exists";
                book = new BookDto();
            }

            var reviewReviewerBookViewModel = new ReviewReviewerBookViewModel()
            {
                Review   = review,
                Reviewer = reviewer,
                Book     = book
            };

            return(View(reviewReviewerBookViewModel));
        }
        public IActionResult GetBookById(int bookid)
        {
            var CompleteBookViewModel = new CompleteBookViewModel()
            {
                ReviewsReviewers = new Dictionary <ReviewDto, ReviewerDto>(),
                AuthorsCountries = new Dictionary <AuthorDto, CountryDto>()
            };

            var book = bookRepositoryGUI.GetBookByID(bookid);

            if (book == null)
            {
                ModelState.AddModelError(string.Empty, "Some kind of error Getting Books");
                book = new BookDto();
            }

            var categories = categoryRepositoryGUI.GetAllCategoriesOfABook(bookid);

            if (categories.Count() <= 0)
            {
                ModelState.AddModelError(string.Empty, "Some kind of Error Getting Categories");
            }

            var rating = bookRepositoryGUI.GetBookRating(bookid);


            CompleteBookViewModel.Book       = book;
            CompleteBookViewModel.Categories = categories;
            CompleteBookViewModel.Rating     = rating;

            var authors = authorRepositoryGUI.GetAuthorsOfABook(bookid);

            if (authors.Count() <= 0)
            {
                ModelState.AddModelError(string.Empty, "Some kind of error Getting Authors");
            }

            foreach (var author in authors)
            {
                var country = countryRepositoryGUI.GetCountryOfAuthor(author.Id);

                CompleteBookViewModel.AuthorsCountries.Add(author, country);
            }

            var reviews = reviewRepositoryGUI.GetReviewsOfABook(bookid);

            if (reviews.Count() <= 0)
            {
                ViewBag.ReviewMsg = $"No Review of {book.Id} ";
            }

            foreach (var review in reviews)
            {
                var reviewer = reviewerRepositoryGUI.GetReviewerOfAReview(review.id);

                CompleteBookViewModel.ReviewsReviewers.Add(review, reviewer);
            }

            if (!ModelState.IsValid)
            {
                ViewBag.bookMsg = "There is an Error Getting the Complete Book Record form the Database";
            }

            return(View(CompleteBookViewModel));
        }