示例#1
0
        // GET: Comments/Create
        public ActionResult CreateComment(CommentQuery q)
        {
            Comment comment = new Comment();

            comment.parentID   = q.id;
            comment.parentType = q.pType;
            return(View(comment));
        }
示例#2
0
        public ActionResult ViewComment(CommentQuery q)
        {
            var comments = from c in db.Comment
                           where c.parentID == q.id
                           where c.parentType == q.pType
                           orderby c.postDate descending
                           select c;

            return(View(comments.ToList()));
        }
示例#3
0
        public ActionResult CreateComment(CommentQuery c, [Bind(Include = "commentID,parentType,parentID,body,postDate,userName,status")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                comment.parentType = c.pType;
                comment.parentID   = c.id;

                comment.userName = Session["username"].ToString();
                comment.postDate = DateTime.Now;
                comment.status   = "visible";


                if (comment.body != "" && comment.body != null)
                {
                    db.Comment.Add(comment);
                    db.SaveChanges();
                    db.Entry(comment).Reload();
                }

                return(findParent(comment));
            }
            return(View(comment));
        }