Beispiel #1
0
        public ActionResult Create(CommentInfo commentInfo)
        {
            if (ModelState.IsValid)
            {
                var comment = new Comment();
                comment.Date = DateTime.Now;
                comment.Text = commentInfo.Text;
                comment.Post = new Post() { PostId = commentInfo.PostId};
                comment.UserPosted = CurrentUser;

                if (commentInfo.CommentId != 0)
                    comment.ToComment = new Comment { CommentId = commentInfo.CommentId };

                repository.SaveComment(comment);
                return RedirectToAction("ShowPost", "Post", new { postId = commentInfo.PostId});
            }
            return View(commentInfo);
        }
Beispiel #2
0
 public ActionResult Create(int postId, int commentId = 0)
 {
     var commentInfo = new CommentInfo {PostId = postId, CommentId = commentId};
     return View(commentInfo);
 }