Пример #1
0
        public ActionResult Create(Comment comment)
        {
            if (ModelState.IsValid)
            {
                db.Comments.Add(comment);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.PostID = new SelectList(db.Posts, "PostID", "Username", comment.PostID);
            return View(comment);
        }
Пример #2
0
 public ActionResult Comment(int id, string name, string email, string body)
 {
     Post post = GetPost(id);
     Comment comment = new Comment();
     comment.Post = post;
     comment.DateTime = DateTime.Now;
     comment.Email = email;
     comment.Body = body;
     comment.Name = name;
     model.Comments.Add(comment);
     model.SaveChanges();
     return RedirectToAction("Details", new{id = id});
 }
Пример #3
0
 public ActionResult Edit(Comment comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.PostID = new SelectList(db.Posts, "PostID", "Username", comment.PostID);
     return View(comment);
 }
Пример #4
0
		private void detach_Comments(Comment entity)
		{
			this.SendPropertyChanging();
			entity.Post = null;
		}
Пример #5
0
		private void attach_Comments(Comment entity)
		{
			this.SendPropertyChanging();
			entity.Post = this;
		}
Пример #6
0
 partial void DeleteComment(Comment instance);
Пример #7
0
 partial void UpdateComment(Comment instance);
Пример #8
0
 partial void InsertComment(Comment instance);