public ActionResult UpdateBook(int id) { Book book = _bookService.GetBookId(id); ViewBag.AuthorId = new SelectList(_authorService.GetAllAuthors(), "ID", "Name", book.AuthorId); ViewBag.GenreId = new SelectList(_genreService.GetAllGenres(), "ID", "Name", book.GenreId); return(View(book)); }
public ActionResult GetReviewByBook(int id) { //First, finding the Id of a Book needed to add a Review. var book = _bookService.GetBookId(id); var reviews = book.Reviews; // Maps the the values from new custom model (ReviewViewModel) to Review entity model. var listofReviews = reviews.Select(review => new ReviewViewModel { Id = review.Id, BookId = review.BookId, BookName = review.Book.Title, ReviewContent = review.ReviewContent, AuthorName = review.User.UserName, DateCreated = review.Created.ToString(), Rating = review.Rating, UserId = review.User.Id }); ViewBag.BookId = id; return(View(listofReviews)); }
public ActionResult GetBookId(int id) { //Grab id of book Book books = _bookService.GetBookId(id); //Map properties of custom view model to raw database entities BookDetailViewModel bookDetail = new BookDetailViewModel() { Id = books.Id, BookTitle = books.Title, BookImage = books.Image, ISBN = books.ISBN, Price = books.Price, Publisher = books.Publisher, Format = books.Format, Blurb = books.Blurb, Year = books.Year, GenreName = books.Genre.Name, AuthorName = books.Author.Name, AuthorId = books.Author.Id }; return(View(bookDetail)); }
public Book GetBookId(int id) { return(_dao.GetBookId(id)); }