Exemplo n.º 1
0
        /// <summary>
        /// Used for adding games to the internal list
        /// </summary>
        public bool AddGame(Model.Game newGame)
        {
            bool wasGameAdded = false;

            if (newGame != null)
            {
                //Make sure a game has a unique id
                if (newGame.Id == Guid.Empty)
                {
                    newGame.Id = Guid.NewGuid();
                }

                datastore.Games.Add(newGame.Clone());
                wasGameAdded = true;
            }

            return(wasGameAdded);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update a game with new changes
        /// </summary>
        public bool UpdateGame(Model.Game game)
        {
            bool wasGameupdated = false;

            if (game != null)
            {
                var gameFromStore = datastore.Games.Where(x => x.Id == game.Id).SingleOrDefault();
                if (gameFromStore != null)
                {
                    datastore.Games.Remove(gameFromStore);
                    AddGame(game);

                    gameFromStore  = game;
                    wasGameupdated = true;
                    UnsavedChanges = true;
                }
            }

            return(wasGameupdated);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Remove a game from the internal list
        /// </summary>
        /// <exception cref="InvalidOperationException">thrown when the game to delete is not found</exception>
        public bool RemoveGame(Model.Game game)
        {
            bool wasGameRemoved = false;

            if (game != null)
            {
                var gameToRemove = datastore.Games.Where(x => x.Id == game.Id).SingleOrDefault();
                if (gameToRemove != null)
                {
                    datastore.Games.Remove(gameToRemove);
                    wasGameRemoved = true;
                }
                else
                {
                    throw new InvalidOperationException("Game was not found in internal game list");
                }
            }

            return(wasGameRemoved);
        }