コード例 #1
0
        private Tournament Map(TournamentQueryContextModel ctx_model)
        {
            return(new Tournament()
            {
                Id = ctx_model.Id,
                Name = ctx_model.Name,
                Created = ctx_model.Created,
                Options = new Options()
                {
                    Tables = ctx_model.Tables,
                    Sets = ctx_model.Sets,
                    Points = ctx_model.Points,
                    PointsDrawn = ctx_model.Points_drawn,
                    Drawn = ctx_model.Drawn,
                    Walkover = ctx_model.Walkover
                },

                Rounds = ctx_model.Rounds.Select(r => TournamentMapper.Map(r, ctx_model.Id))
            });
        }
コード例 #2
0
        public IMessageContext Load(IMessage input)
        {
            _ctx_model = new TournamentQueryContextModel();
            var query             = input as TournamentQuery;
            var tournament_events = _es.Replay(new TournamentContext(query.TournamentId, nameof(TournamentContext)));
            var person_events     = _es.Replay(typeof(PersonUpdated));

            var tournament_event    = tournament_events.First(e => e is TournamentCreated);
            var option_events       = tournament_events.Where(e => e is OptionsCreated);
            var round_events        = tournament_events.Where(e => e is RoundCreated);
            var match_events        = tournament_events.Where(e => e is MatchCreated);
            var match_played_events = tournament_events.Where(e => e is MatchPlayed || e is MatchReseted);

            Apply(tournament_event as TournamentCreated);
            foreach (var ev in option_events)
            {
                Apply(ev as OptionsCreated);
            }
            foreach (var ev in round_events)
            {
                Apply(ev as RoundCreated);
            }
            foreach (var ev in match_events)
            {
                Apply(ev as MatchCreated);
            }
            foreach (var ev in match_played_events)
            {
                Apply(ev);
            }
            foreach (var ev in person_events)
            {
                Apply(ev as PersonUpdated);
            }

            return(_ctx_model);
        }