Ejemplo n.º 1
0
 public void UpdateGame(Game game)
 {
     using (var db = new AvalonContext())
     {
         var retrievedGame = db.Games.Find(game.GameId);
         if (retrievedGame != null)
         {
             db.Entry(retrievedGame).CurrentValues.SetValues(game);
             db.SaveChanges();
         }
         else
         {
             throw new GameGatewayException("Game with id " + game.GameId + " does not exist!");
         }
     }
 }
Ejemplo n.º 2
0
        public void UpdatePlayer(Player player)
        {
            using (var db = new AvalonContext())
            {
                String[] usernameArray   = { player.DisplayName };
                var      retrievedPlayer = db.Players.Find(usernameArray);

                if (retrievedPlayer != null)
                {
                    db.Entry(retrievedPlayer).CurrentValues.SetValues(player);
                    db.SaveChanges();
                }
                else
                {
                    throw new PlayerGatewayException("Player with username " + player.DisplayName + " does not exist.");
                }
            }
        }