public ActionResult SaveComment(ViewModels.Book.Details model) { var comment = new Comments(); var ID = System.Web.HttpContext.Current.User.Identity.GetUserId(); comment.Comment = model.Comment; db.Comments.Add(comment); db.SaveChanges(); return(View(model)); }
public ActionResult DetailsBackToHome(int?Id) { var book = db.Books.Find(Id); var authors = db.Authors.Find(book.AuthorID); var categories = db.Category.Find(book.CategoryID); var commentsById = db.Comments.Where(a => (a.BookID == book.BookID)).ToList() == null ? null : db.Comments.Where(a => (a.BookID == book.BookID)).ToList(); var model = new ViewModels.Book.Details(authors, categories, book, commentsById); TempData["LastBookId"] = book.BookID; return(View("DetailsBackToHome", model)); }