public void Handle(PlayerRenamedEvent e) { var dto = QueryDataStore.GetData <GetGameResultsDto>().Single(x => x.GameId == e.AggregateId); var renamedPlayer = dto.Players.First(p => p.PlayerName == e.OldPlayerName); renamedPlayer.PlayerName = e.NewPlayerName; QueryDataStore.SaveChanges(); }
public void Handle(PlayerRenamedEvent e) { var players = QueryDataStore.GetData <GetPlayerGamesDto>().Where(x => x.PlayerName == e.OldPlayerName).ToList(); foreach (var p in players) { p.PlayerName = e.NewPlayerName; } QueryDataStore.SaveChanges(); }
public void Handle(PlayerRenamedEvent e) { var games = QueryDataStore.GetData <GetGamesListDto>().Where(x => x.Winner == e.OldPlayerName); foreach (var g in games) { g.Winner = e.NewPlayerName; } QueryDataStore.SaveChanges(); }
public void Handle(PlayerAddedToGameEvent e) { var game = QueryDataStore.GetData <GetGamesListDto>().First(x => x.GameId == e.AggregateId); if (e.Placing == 1) { game.Winner = e.PlayerName; game.Winnings = e.Winnings; } QueryDataStore.SaveChanges(); }
public void Handle(PlayerAddedToGameEvent e) { var game = QueryDataStore.GetData <GetGameResultsDto>().Single(x => x.GameId == e.AggregateId); game.Players.Add(new GetGameResultsDto.PlayerDto() { PlayerName = e.PlayerName, Placing = e.Placing, Winnings = e.Winnings, PayIn = e.PayIn }); QueryDataStore.SaveChanges(); }
public void Handle(GameDeletedEvent e) { var players = QueryDataStore.GetData <LookupGamePlayersDto>().Where(x => x.GameId == e.AggregateId); foreach (var p in players) { var stats = QueryDataStore.GetData <GetPlayerStatisticsDto>().First(x => x.PlayerName == p.PlayerName); stats.GamesPlayed--; stats.Winnings -= p.Winnings; stats.PayIn -= p.PayIn; stats.Profit -= p.Winnings - p.PayIn; stats.ProfitPerGame = stats.Profit == 0 ? 0 : stats.Profit / stats.GamesPlayed; QueryDataStore.SaveChanges(); } }
public void Handle(PlayerAddedToGameEvent e) { var player = QueryDataStore.GetData <GetPlayerStatisticsDto>().FirstOrDefault(x => x.PlayerName == e.PlayerName); if (player == null) { player = new GetPlayerStatisticsDto(); AddGameToPlayer(player, e); QueryDataStore.Insert <GetPlayerStatisticsDto>(player); } else { AddGameToPlayer(player, e); QueryDataStore.SaveChanges(); } }