public IActionResult Details(int?id) { if (id == null) { return(View("Index")); } var book = _bookService.GetBookById(id); var reviews = _reviewService.GetAllReviewsByBookID(id); reviews.Reverse(); if (book == null) { return(RedirectToAction("Index", "Home")); } var bookAndReviews = new BookAndReviewListViewModel { BookId = book.BookId, Title = book.Title, Author = book.Author, ReleaseYear = book.ReleaseYear, Genre = book.Genre, ISBN = book.ISBN, Price = book.Price, Stock = book.Stock, ReviewScore = book.ReviewScore, TopSeller = book.TopSeller, OnSale = book.OnSale, Discount = book.Discount, Image = book.Image, Reviews = reviews }; if (bookAndReviews == null) { return(View("Index")); } return(View(bookAndReviews)); }