public ActionResult Delete(User UserView) { DBEntities DB = new DBEntities(); List <Bookmark> Bookmarks = DB.Bookmarks.Where(x => x.UserId == UserView.Id).ToList(); foreach (var bookmark in Bookmarks) { DB.Delete(bookmark); } DB.Delete(DB.Users.Where(x => x.Id == UserView.Id).FirstOrDefault()); DB.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(Bookmark bookmark) { bookmark = DB.Bookmarks.Where(x => x.Id == bookmark.Id).First(); DB.Delete(bookmark); DB.SaveChanges(); return(RedirectToAction("Index")); }