public ActionResult Forum(CommentModel model, int id = 0) { PostModel post = db.Posts.Find(id); if (post == null) { return HttpNotFound(); } if (model.Likes != 0 && model.Dislikes != 0) { post.Comments.Add(model); } return View(post); }
public ActionResult AddComment(CommentModel model, int id = 0) { PostModel post = db.Posts.Find(id); if (ModelState.IsValid) { db.Comments.Add(model); db.SaveChanges(); return RedirectToAction("Forum", new { id = id }); } return View(model); }