コード例 #1
0
        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"));
        }
コード例 #2
0
        public ActionResult Delete(Bookmark bookmark)
        {
            bookmark = DB.Bookmarks.Where(x => x.Id == bookmark.Id).First();
            DB.Delete(bookmark);

            DB.SaveChanges();

            return(RedirectToAction("Index"));
        }