public void Handle(GameCompletedEvent e) { foreach (var p in e.Placings) { var player = QueryDataStore.GetData <PlayerLookupDto>().Single(x => x.PlayerId == p.Key); var dto = QueryDataStore.GetData <GetGamePlayersDto>().Single(x => x.GameId == e.GameId && x.PlayerId == player.PlayerId); dto.Placing = p.Value; if (dto.Placing == 1) { dto.Winnings = e.First; } if (dto.Placing == 2) { dto.Winnings = e.Second; } if (dto.Placing == 3) { dto.Winnings = e.Third; } QueryDataStore.Update(dto); } }
public void Handle(GameUncompletedEvent e) { var dto = QueryDataStore.GetData <GameLookupDto>().Single(x => x.GameId == e.GameId); dto.Completed = false; QueryDataStore.Update(dto); }
public void Handle(GameDateChangedEvent e) { var dto = QueryDataStore.GetData <GameLookupDto>().Single(x => x.GameId == e.GameId); dto.GameDate = e.GameDate; QueryDataStore.Update(dto); }
public void Handle(RebuyRemovedEvent e) { var dto = QueryDataStore.GetData <GetGamePlayersDto>().Single(p => p.GameId == e.GameId && p.PlayerId == e.PlayerId); dto.PayIn -= 10; QueryDataStore.Update(dto); }
public void Handle(GameUncompletedEvent e) { var dto = QueryDataStore.GetData <GetGamesListDto>().Single(); dto.Completed = false; QueryDataStore.Update(dto); }
public void Handle(GameDeletedEvent e) { var dtos = QueryDataStore.GetData <GetGamesWithPlayerDto>().Where(x => x.GameId == e.AggregateId).ToList(); foreach (var d in dtos) { QueryDataStore.Delete <GetGamesWithPlayerDto>(d); } }
public void Handle(RebuyAddedEvent e) { var dto = QueryDataStore.GetData <GetGamePlayersDto>().Single(p => p.GameId == e.GameId && p.PlayerId == e.PlayerId); dto.PayIn += e.RebuyAmount; dto.Rebuys++; QueryDataStore.Update(dto); }
public void Handle(GameDeletedEvent e) { var games = QueryDataStore.GetData <GetPlayerGamesDto>().Where(x => x.GameId == e.AggregateId).ToList(); foreach (var g in games) { QueryDataStore.Delete <GetPlayerGamesDto>(g); } }
public void Handle(GameCompletedEvent e) { foreach (var player in e.Placings) { var dto = QueryDataStore.GetData <GetPlayersDto>().Single(p => p.PlayerId == player.Key); dto.GamesPlayed++; QueryDataStore.Update(dto); } }
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(GameUncompletedEvent e) { // How does this Single even work, shouldn't we need to filter by GameId // should probably write a test for this first var dto = QueryDataStore.GetData <GetGamesListDto>().Single(); dto.Completed = false; QueryDataStore.Update(dto); }
public void Handle(GameDateChangedEvent e) { var dto = QueryDataStore.GetData <GetGameCountByDateDto>().Single(x => x.GameId == e.GameId); dto.GameYear = e.GameDate.Year; dto.GameMonth = e.GameDate.Month; dto.GameDay = e.GameDate.Day; QueryDataStore.Update <GetGameCountByDateDto>(dto); }
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(GameUncompletedEvent e) { var gamePlayersDto = QueryDataStore.GetData <GamePlayersLookupDto>().Where(x => x.GameId == e.GameId).ToList(); foreach (var player in gamePlayersDto) { var dto = QueryDataStore.GetData <GetPlayersDto>().Single(x => x.PlayerId == player.PlayerId); dto.GamesPlayed--; QueryDataStore.Update(dto); } }
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 player = QueryDataStore.GetData <PlayerLookupDto>().Single(p => p.PlayerId == e.PlayerId); QueryDataStore.Insert(new GetGamePlayersDto() { GameId = e.GameId, PlayerId = e.PlayerId, PlayerName = player.PlayerName, }); }
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(PlayerAddedToGameEvent e) { var gameDateDto = QueryDataStore.GetData <LookupGameDatesDto>().Single(x => x.GameId == e.AggregateId); var dto = new GetPlayerGamesDto(); dto.GameId = e.AggregateId; dto.GameDate = gameDateDto.GameDate; dto.PlayerName = e.PlayerName; dto.Placing = e.Placing; dto.Winnings = e.Winnings; dto.PayIn = e.PayIn; QueryDataStore.Insert <GetPlayerGamesDto>(dto); }
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(GameCompletedEvent e) { var winnerId = e.Placings.Single(p => p.Value == 1).Key; var winner = QueryDataStore.GetData <PlayerLookupDto>().Single(p => p.PlayerId == winnerId); var game = QueryDataStore.GetData <GetGamesListDto>().Single(g => g.GameId == e.GameId); var dto = new GetGamesListDto() { DtoId = game.DtoId, GameId = e.GameId, GameDate = game.GameDate, Winner = winner.PlayerName, Winnings = e.First, Completed = true, }; QueryDataStore.Update(dto); }
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(); } }
public void Handle(PlayerRemovedFromGameEvent e) { var dto = QueryDataStore.GetData <GetGamePlayersDto>().Single(p => p.GameId == e.GameId && p.PlayerId == e.PlayerId); QueryDataStore.Delete(dto); }
public void Handle(GameDeletedEvent e) { var dto = QueryDataStore.GetData <GetGamesListDto>().Single(d => d.GameId == e.GameId); QueryDataStore.Delete(dto); }
public void Handle(GameDeletedEvent e) { var dto = QueryDataStore.GetData <GetGamesListDto>().Single(x => x.GameId == e.AggregateId); QueryDataStore.Delete <GetGamesListDto>(dto); }
public void Handle(GameDeletedEvent e) { var dto = QueryDataStore.GetData <GetGameCountByDateDto>().Single(d => d.GameId == e.AggregateId); QueryDataStore.Delete <GetGameCountByDateDto>(dto); }
public void Handle(PlayerDeletedEvent e) { var dto = QueryDataStore.GetData <GetPlayersDto>().Single(p => p.PlayerId == e.PlayerId); QueryDataStore.Delete(dto); }
public void Handle(PlayerRemovedFromGameEvent e) { var dto = QueryDataStore.GetData <GamePlayersLookupDto>().Single(x => x.GameId == e.GameId && x.PlayerId == e.PlayerId); QueryDataStore.Delete(dto); }
public void Handle(PlayerDeletedEvent e) { var dto = QueryDataStore.GetData <GetPlayerCountByNameDto>().Single(d => d.PlayerId == e.PlayerId); QueryDataStore.Delete(dto); }