public ActionResult Edit([Bind(Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName")] AspNetUser aspNetUser) { if (ModelState.IsValid) { db.Entry(aspNetUser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aspNetUser)); }
// Comment table public static bool AddComment(Comment comment) { using (Model2Container ctx = new Model2Container()) { bool bResult = false; if (comment == null || comment.PostPostId == 0) { return(bResult); } if (comment.Id == 0) { ctx.Entry <Comment>(comment).State = EntityState.Added; Post p = ctx.Posts.Find(comment.PostPostId); ctx.Entry <Post>(p).State = EntityState.Unchanged; ctx.SaveChanges(); bResult = true; } return(bResult); } }
public static bool AddPost(Post post) { using (Model2Container ctx = new Model2Container()) { bool bResult = false; if (post.PostId == 0) { var it = ctx.Entry <Post>(post).State = EntityState.Added; ctx.SaveChanges(); bResult = true; } return(bResult); } }