private RankingDataBasis Map(TournamentRankingQueryContextModel model)
        {
            var options_data = new RankingDataBasis.RankingOptionsData()
            {
                Points       = model.Tournament_options.Points,
                Points_drawn = model.Tournament_options.Points_drawn,
                Drawn        = model.Tournament_options.Drawn,
                Walkover     = model.Tournament_options.Walkover
            };

            var players_data = model.Players.Select(p => new RankingDataBasis.RankingPlayerData()
            {
                Player_id   = p.Id,
                Player_name = p.Name
            }).ToList();

            var match_datas = model.Matches.Select(m => new RankingDataBasis.RankingMatchData()
            {
                Home  = Map(m.Home),
                Away  = Map(m.Away),
                Drawn = m.Drawn
            }).ToList();

            return(new RankingDataBasis()
            {
                Options = options_data,
                Players = players_data,
                Matches = match_datas,
                Walkover_played = model.Walkover
            });
        }
        public IMessageContext Load(IMessage input)
        {
            _ctx_model = new TournamentRankingQueryContextModel();
            var query             = input as TournamentRankingQuery;
            var tournament_events = _es.Replay(new TournamentContext(query.TournamentId, nameof(TournamentContext)));
            var person_events     = _es.Replay(typeof(PersonUpdated));

            var tournament_option_events = tournament_events.Where(e => e is OptionsCreated);
            var players_events           = tournament_events.Where(e => e is PlayersStored);
            var match_events             = tournament_events.Where(e => e is MatchCreated);
            var match_played_events      = tournament_events.Where(e => e is MatchPlayed || e is MatchReseted);
            var walkover_played_events   = tournament_events.Where(e => e is WalkoverPlayed);

            foreach (var ev in tournament_option_events)
            {
                Apply(ev as OptionsCreated);
            }
            foreach (var ev in players_events)
            {
                Apply(ev as PlayersStored);
            }
            foreach (var ev in match_events)
            {
                Apply(ev as MatchCreated);
            }
            foreach (var ev in match_played_events)
            {
                Apply(ev);
            }
            foreach (var ev in walkover_played_events)
            {
                Apply(ev as WalkoverPlayed);
            }
            foreach (var ev in person_events)
            {
                Apply(ev as PersonUpdated);
            }

            return(_ctx_model);
        }