public ActionResult DeleteComment(int id) { AnComment anComment = db.AnComments.Find(id); db.AnComments.Remove(anComment); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult PostComment(string AnComment) { if (AnComment == "") { return(RedirectToAction("Error")); } int userid = 2; AnComment comment = new AnComment(); comment.UserId = userid; comment.CommentText = AnComment; db.AnComments.Add(comment); db.SaveChanges(); return(RedirectToAction("Index")); }