Esempio n. 1
0
        public static void deleteGame(Game games)
        {
            GameStoreDB db = new GameStoreDB();

            if (games != null)
            {
                var game = db.Games.Find(games.GameID);
                db.Games.Remove(game);
                db.SaveChanges();
                MessageBox.Show("Game Deleted!");
            }
            else
            {
                MessageBox.Show("You did not select a game to delete!");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adds or updates a game depending on whether
        /// the user added a new game or tried to update
        /// a current game.
        /// </summary>
        /// <param name="game">A game that is being passed to the method to be updated or added.</param>
        public static void AddOrUpdateGame(Game game)
        {
            GameStoreDB db = new GameStoreDB();
            Game        g  = db.Games.Find(game.GameID);

            if (g == null)
            {
                db.Games.Add(game);
                MessageBox.Show("Game Added");
            }
            else
            {
                g.GameName       = game.GameName;
                g.NumberOfCopies = game.NumberOfCopies;
                g.Price          = game.Price;
                g.Availability   = game.Availability;
                MessageBox.Show("Game Updated");
            }

            db.SaveChanges();
        }