public bool AddGame(int gameId, Set set) { Game game = new Game(gameId); if (game != null) { game.Set = set; _context.Games.Add(game); _context.SaveChanges(); if (_context.Games.Find(gameId) != null) { return(true); } } return(false); }
public CardsController(CardsContext context) { db = context; if (!db.Cards.Any()) { db.Cards.Add(new Card { Title = "Milk", Url = "/img/milk.jpg" }); db.Cards.Add(new Card { Title = "Bread", Url = "/img/bread.jpg" }); db.SaveChanges(); } }
public void SaveChanges() => _context.SaveChanges();