Пример #1
0
    public void Handle(SerieRegistered e, string aggregateId)
    {
        Roster        roster        = DocumentSession.Load <Roster>(e.RosterId);
        string        id            = SeasonResults.GetId(roster.Season);
        SeasonResults seasonResults = DocumentSession.Load <SeasonResults>(id);

        seasonResults.Add(roster.BitsMatchId, roster.Id !, roster.Date, roster.Turn, e.MatchSerie);
    }
Пример #2
0
    public void Handle(SerieRegistered e, string aggregateId)
    {
        foreach (MatchTable table in new[] { e.MatchSerie.Table1, e.MatchSerie.Table2, e.MatchSerie.Table3, e.MatchSerie.Table4 })
        {
            string id1 = ResultForPlayerReadModel.GetId(table.Game1.Player, e.BitsMatchId, e.RosterId);
            DocumentSession.Load <ResultForPlayerReadModel>(id1).AddGame(table.Score, table.Game1);

            string id2 = ResultForPlayerReadModel.GetId(table.Game2.Player, e.BitsMatchId, e.RosterId);
            DocumentSession.Load <ResultForPlayerReadModel>(id2).AddGame(table.Score, table.Game2);
        }
    }
Пример #3
0
    public void Handle(SerieRegistered e, string aggregateId)
    {
        string     id         = TeamOfWeek.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        TeamOfWeek teamOfWeek = DocumentSession.Load <TeamOfWeek>(id);

        Domain.Match.MatchSerie    matchSerie = e.MatchSerie;
        Tuple <string, int, int>[] playerIds  = new[]
        {
            Tuple.Create(
                matchSerie.Table1.Game1.Player,
                matchSerie.Table1.Score,
                matchSerie.Table1.Game1.Pins),
            Tuple.Create(
                matchSerie.Table1.Game2.Player,
                matchSerie.Table1.Score,
                matchSerie.Table1.Game2.Pins),
            Tuple.Create(
                matchSerie.Table2.Game1.Player,
                matchSerie.Table2.Score,
                matchSerie.Table2.Game1.Pins),
            Tuple.Create(
                matchSerie.Table2.Game2.Player,
                matchSerie.Table2.Score,
                matchSerie.Table2.Game2.Pins),
            Tuple.Create(
                matchSerie.Table3.Game1.Player,
                matchSerie.Table3.Score,
                matchSerie.Table3.Game1.Pins),
            Tuple.Create(
                matchSerie.Table3.Game2.Player,
                matchSerie.Table3.Score,
                matchSerie.Table3.Game2.Pins),
            Tuple.Create(
                matchSerie.Table4.Game1.Player,
                matchSerie.Table4.Score,
                matchSerie.Table4.Game1.Pins),
            Tuple.Create(
                matchSerie.Table4.Game2.Player,
                matchSerie.Table4.Score,
                matchSerie.Table4.Game2.Pins)
        };
        HashSet <string> uniquePlayerIds = new(playerIds.Select(x => x.Item1));

        Player[] players = DocumentSession.Load <Player>(uniquePlayerIds);
        foreach (Player player in players)
        {
            string playerId = player.Id;
            foreach (Tuple <string, int, int> tuple in playerIds.Where(x => x.Item1 == playerId))
            {
                teamOfWeek.AddResultForPlayer(player, tuple.Item2, tuple.Item3);
            }
        }
    }
Пример #4
0
    private void Apply(SerieRegistered e)
    {
        registeredSeries++;
        foreach (MatchTable table in new[] { e.MatchSerie.Table1, e.MatchSerie.Table2, e.MatchSerie.Table3, e.MatchSerie.Table4 })
        {
            if (playerPins.ContainsKey(table.Game1.Player) == false)
            {
                playerPins.Add(table.Game1.Player, new List <PinsAndScoreResult>());
            }

            playerPins[table.Game1.Player].Add(new PinsAndScoreResult(table.Game1.Pins, table.Score, registeredSeries));

            if (playerPins.ContainsKey(table.Game2.Player) == false)
            {
                playerPins.Add(table.Game2.Player, new List <PinsAndScoreResult>());
            }

            playerPins[table.Game2.Player].Add(new PinsAndScoreResult(table.Game2.Pins, table.Score, registeredSeries));
        }
    }
Пример #5
0
    public void Handle(SerieRegistered e, string aggregateId)
    {
        string id = ResultSeriesReadModel.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        ResultSeriesReadModel results = DocumentSession.Load <ResultSeriesReadModel>(id);

        MatchSerie       matchSerie = e.MatchSerie;
        HashSet <string> playerIds  = new()
        {
            matchSerie.Table1.Game1.Player,
            matchSerie.Table1.Game2.Player,
            matchSerie.Table2.Game1.Player,
            matchSerie.Table2.Game2.Player,
            matchSerie.Table3.Game1.Player,
            matchSerie.Table3.Game2.Player,
            matchSerie.Table4.Game1.Player,
            matchSerie.Table4.Game2.Player
        };

        Dictionary <string, Player> players = DocumentSession.Load <Player>(playerIds).ToDictionary(x => x.Id);

        ResultSeriesReadModel.Table table1 = CreateTable(players, matchSerie.Table1);
        ResultSeriesReadModel.Table table2 = CreateTable(players, matchSerie.Table2);
        ResultSeriesReadModel.Table table3 = CreateTable(players, matchSerie.Table3);
        ResultSeriesReadModel.Table table4 = CreateTable(players, matchSerie.Table4);

        results.Series.Add(new ResultSeriesReadModel.Serie
        {
            Tables = new List <ResultSeriesReadModel.Table>
            {
                table1,
                table2,
                table3,
                table4
            }
        });
    }