public ActionResult DeleteComment(Comment comment) { db.Entry(comment).State = System.Data.EntityState.Deleted; db.SaveChanges(); return RedirectToAction("Posts"); }
public ActionResult Comment(Comment comment) { var user = db.Users.Where(e => e.UserName == HttpContext.User.Identity.Name).FirstOrDefault(); comment.CommentDateTime = DateTime.Now; comment.UserId = user.Id; db.Entry(comment).State = System.Data.EntityState.Added; db.SaveChanges(); return RedirectToAction("Posts"); }