public void Handle(Serie4Registered e, string aggregateId)
    {
        string id = ResultSeries4ReadModel.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        ResultSeries4ReadModel results = DocumentSession.Load <ResultSeries4ReadModel>(id);

        MatchSerie4 matchSerie = e.MatchSerie;

        string[] playerIds = new[]
        {
            matchSerie.Game1.Player,
            matchSerie.Game2.Player,
            matchSerie.Game3.Player,
            matchSerie.Game4.Player
        };

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

        ResultSeries4ReadModel.Game game1 = CreateGame(players, matchSerie.Game1);
        ResultSeries4ReadModel.Game game2 = CreateGame(players, matchSerie.Game2);
        ResultSeries4ReadModel.Game game3 = CreateGame(players, matchSerie.Game3);
        ResultSeries4ReadModel.Game game4 = CreateGame(players, matchSerie.Game4);

        results.Series.Add(new ResultSeries4ReadModel.Serie
        {
            Games = new List <ResultSeries4ReadModel.Game>
            {
                game1,
                game2,
                game3,
                game4
            }
        });
    }
Example #2
0
    public void Handle(Serie4Registered e, string aggregateId)
    {
        string     id         = TeamOfWeek.IdFromBitsMatchId(e.BitsMatchId, e.RosterId);
        TeamOfWeek teamOfWeek = DocumentSession.Load <TeamOfWeek>(id);

        Domain.Match.MatchSerie4   matchSerie = e.MatchSerie;
        Tuple <string, int, int>[] playerIds  = new[]
        {
            Tuple.Create(
                matchSerie.Game1.Player,
                matchSerie.Game1.Score,
                matchSerie.Game1.Pins),
            Tuple.Create(
                matchSerie.Game2.Player,
                matchSerie.Game2.Score,
                matchSerie.Game2.Pins),
            Tuple.Create(
                matchSerie.Game3.Player,
                matchSerie.Game3.Score,
                matchSerie.Game3.Pins),
            Tuple.Create(
                matchSerie.Game4.Player,
                matchSerie.Game4.Score,
                matchSerie.Game4.Pins)
        };
        Player[] players = DocumentSession.Load <Player>(playerIds.Select(x => x.Item1));
        foreach (Player player in players)
        {
            string playerId = player.Id;
            Tuple <string, int, int> tuple = playerIds.Single(x => x.Item1 == playerId);
            teamOfWeek.AddResultForPlayer(player, tuple.Item2, tuple.Item3);
        }
    }
    public void Handle(Serie4Registered 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);
    }
Example #4
0
 public void Handle(Serie4Registered e, string aggregateId)
 {
     foreach (MatchGame4 game in new[] { e.MatchSerie.Game1, e.MatchSerie.Game2, e.MatchSerie.Game3, e.MatchSerie.Game4 })
     {
         string id = ResultForPlayerReadModel.GetId(game.Player, e.BitsMatchId, e.RosterId);
         DocumentSession.Load <ResultForPlayerReadModel>(id).AddGame(game);
     }
 }
Example #5
0
    private void Apply(Serie4Registered e)
    {
        registeredSeries++;
        foreach (MatchGame4 game in new[] { e.MatchSerie.Game1, e.MatchSerie.Game2, e.MatchSerie.Game3, e.MatchSerie.Game4 })
        {
            if (playerPins.ContainsKey(game.Player) == false)
            {
                playerPins.Add(game.Player, new List <PinsAndScoreResult>());
            }

            PinsAndScoreResult pinsAndScoreResult = new(
                game.Pins,
                game.Score,
                registeredSeries);
            playerPins[game.Player].Add(pinsAndScoreResult);
        }
    }