Exemplo n.º 1
0
        public ActionResult Comment(Comment comment)
        {
            var comments =   Session["comments"] as List<Comment>;
            if (comments == null)
            { comments = new List<Comment>(); }
            comments.Add(comment);
            Session["comments"] = comments;

            return RedirectToAction("Comments");
        }
Exemplo n.º 2
0
        public ActionResult AddComment(Comment newComment)
        {
            var post = db.Posts.Find( newComment.PostID );

            if (ModelState.IsValid)
            {
                newComment.Created = System.DateTimeOffset.Now;
                newComment.AuthorId = User.Identity.GetUserId();
                db.Comments.Add(newComment);
                db.SaveChanges();
            }
            return RedirectToAction("Details", "BlogPosts", new { Slug = post.Slug});
        }