コード例 #1
0
        public ActionResult Create(string topicID, string commentID, string description)
        {
            try {
                // TODO: Add insert logic here
                using (blogEntities ct = new blogEntities()) {
                    Comment c = new Comment();

                    c.Author = base.Passport.AccountID;
                    c.CreateTime = DateTime.Now;
                    c.Description = description;
                    c.ID = Guid.NewGuid();
                    c.IP = Request.UserHostAddress;

                    if (!string.IsNullOrWhiteSpace(commentID))
                        c.ParentId = Guid.Parse(commentID);
                    c.TopicID = Guid.Parse(topicID);

                    ct.Comments.Add(c);
                    ct.SaveChanges();
                }

                return RedirectToAction("Index", "Home");
            }
            catch {
                return View();
            }
        }
コード例 #2
0
        public ActionResult AddComment()
        {
            Comment c = new Comment();

            c.Description = "asdfasdf";

            return View(c);
        }
コード例 #3
0
        public ActionResult AddComment(string description, Guid topicId)
        {
            using (blogEntities ct = new blogEntities()) {
                Comment comment = new Comment();

                comment.ID = Guid.NewGuid();
                comment.CreateTime = DateTime.Now;
                comment.Author = base.Passport.AccountID;
                comment.IP = Request.UserHostAddress;
                comment.Description = description;
                comment.TopicID = topicId;

                ct.Comments.Add(comment);

                ct.SaveChanges();

                return View(comment);
            }

            //return RedirectToAction("index", "home");
        }