Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }