Exemple #1
0
        public ActionResult AddComment(ViewPostViewModel model)
        {
            ModelState.Clear();

            model.New.Post = postRepository.Posts.Find(model.PostId);
            model.New.User = (User)HttpContext.Session["user"];

            TryValidateModel(model.New, "New");

            if (ModelState.IsValid)
            {
                Comment comment = commentRepository.CreateOrUpdate(model.New);
                TempData["message"] = "Comment added";
            }


            return(RedirectToAction("ViewPost", model.PostId));
        }