示例#1
0
        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);
        }
示例#2
0
 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();
     }
 }
示例#3
0
 public void SaveChanges() => _context.SaveChanges();