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 GetReviewerById(int reviewerid)
        {
            var reviewer = _reviewerRepositoryGUI.GetReviewerByID(reviewerid);

            if (reviewer == null)
            {
                ModelState.AddModelError(string.Empty, "Some Error Occur here in reviewer Controoler");
                ViewBag.reviewerMessage = $"There was pro. in database or reivewer with {reviewerid} does not exist";

                reviewer = new ReviewerDto();
            }

            var reviews = _reviewerRepositoryGUI.GetReviewsByReviewers(reviewerid);

            if (reviews.Count() <= 0)
            {
                ViewBag.reviewMessage = $"REviewer {reviewer.FirstName} {reviewer.LastName} does not exist";
            }

            IDictionary <ReviewDto, BookDto> reviewBook = new Dictionary <ReviewDto, BookDto>();

            foreach (var review in reviews)
            {
                var book = reviewRepositoryGUI.GetBookOfAReview(review.id);

                reviewBook.Add(review, book);
            }


            var reviewerReviewsBook = new ReviewerReviewsBooksViewModel
            {
                ReviewBook = reviewBook,
                Review     = reviewer
            };

            ViewBag.SuccessMessage = TempData["SuccessMessage"];
            return(View(reviewerReviewsBook));
        }
        public IActionResult GetReviewerById(int reviewerId)
        {
            var reviewer = _reviewerRepository.GetReviewerById(reviewerId);

            if (reviewer == null)
            {
                ModelState.AddModelError("", "Some kind of error getting reviewer");
                ViewBag.ReviewerMessage = $"There was a problem retrieving reviewer with id {reviewerId} " +
                                          $"From the database or no reviewer with that id exists";
                reviewer = new ReviewerDto();
            }

            var reviews = _reviewerRepository.GetReviewsByReviewer(reviewerId);

            if (reviews.Count() <= 0)
            {
                ViewBag.ReviewMessage = $"Reviewer {reviewer.FirstName} {reviewer.LastName} has no reviews";
            }

            IDictionary <ReviewDto, BookDto> reviewAndBook = new Dictionary <ReviewDto, BookDto>();

            foreach (var review in reviews)
            {
                var book = _reviewRepository.GetBookOfAReview(review.Id);
                reviewAndBook.Add(review, book);
            }

            var reviewerReviewsBooksViewModel = new ReviewerReviewsBooksViewModel()
            {
                Reviewer   = reviewer,
                ReviewBook = reviewAndBook
            };

            ViewBag.SuccessMessage = TempData["SuccessMessage"];
            return(View(reviewerReviewsBooksViewModel));
        }
        public IActionResult GetReviewerById(int reviewerId)
        {
            var reviewer = _reviewerRepository.GetReviewerById(reviewerId);

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

            var reviews = _reviewerRepository.GetReviewsByAReviewer(reviewerId);

            if (reviews.Count() <= 0)
            {
                ViewBag.ReviewsMessage = $"Reviewer {reviewer.FirstName} {reviewer.LastName} " +
                                         $"has no any reviews at this time, please come back later";
            }

            IDictionary <ReviewDto, BookDto> reviewAndBook = new Dictionary <ReviewDto, BookDto>();

            foreach (var review in reviews)
            {
                var book = _reviewRepository.GetBookOfAReview(review.Id);
                reviewAndBook.Add(review, book);
            }

            var reviewerReviewsBooksViewModel = new ReviewerReviewsBooksViewModel()
            {
                Reviewer   = reviewer,
                ReviewBook = reviewAndBook
            };

            return(View(reviewerReviewsBooksViewModel));
        }