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); }
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}); }
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); }
private void detach_Comments(Comment entity) { this.SendPropertyChanging(); entity.Post = null; }
private void attach_Comments(Comment entity) { this.SendPropertyChanging(); entity.Post = this; }
partial void DeleteComment(Comment instance);
partial void UpdateComment(Comment instance);
partial void InsertComment(Comment instance);