Beispiel #1
0
 public IActionResult Delete(Game game)
 {
     using (var db = new GameStoreDbContext())
     {
         db.Remove(game);
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
        public void DeleteById(int id)
        {
            using (var db = new GameStoreDbContext())
            {
                var game = db.Games.FirstOrDefault(g => g.Id == id);

                if (game != null)
                {
                    db.Remove(game);
                }

                db.SaveChanges();
            }
        }
Beispiel #3
0
        public bool DeleteGame(string title)
        {
            using (var db = new GameStoreDbContext())
            {
                var game = db.Games.FirstOrDefault(g => g.Title == title);
                if (game == null)
                {
                    return(false);
                }

                db.Remove(game);
                db.SaveChanges();

                return(true);
            }
        }
        public bool Delete(int id)
        {
            using (var context = new GameStoreDbContext())
            {
                var game = context.Games.FirstOrDefault(g => g.Id == id);

                if (game == null)
                {
                    return(false);
                }

                context.Remove(game);
                context.SaveChanges();

                return(true);
            }
        }