예제 #1
0
 public ActionResult Edit(Comment comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(comment);
 }
예제 #2
0
        public ActionResult Create(Comment comment)
        {
            if (ModelState.IsValid)
            {
                db.Comments.Add(comment);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(comment);
        }
예제 #3
0
        public ActionResult Comment(int id, string name, string email, string body)
        {
            Blog blog = db.Blogs.Find(id);
            Comment comment = new Comment();
            comment.Blog = blog;
            comment.DateTime = DateTime.Now;
            comment.Name = name;
            comment.Email = email;
            comment.Body = body;
            db.Comments.Add(comment);
            db.SaveChanges();

            return RedirectToAction("Details", new { id =  id});
        }