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!"); } } }
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."); } } }