示例#1
0
        public MatchViewModel GetCurrentState(String matchId)
        {
            IReadOnlyCollection <DomainEvent> events = _eventRepository.GetEventStreamFor(matchId);

            CommandStack.Match matchInfo = EventHelper.PlayEvents(matchId, events.ToList());
            return(new MatchViewModel(matchInfo));
        }
示例#2
0
        private void UpdateSnapshots(String matchId)
        {
            IReadOnlyCollection <DomainEvent> events = _eventRepository.GetEventStreamFor(matchId);

            CommandStack.Match matchInfo = EventHelper.PlayEvents(matchId, events.ToList());

            var lm = (from m in _dbContext.Matches where m.Id == matchId select m).FirstOrDefault();

            if (lm == null)
            {
                var liveMatch = new LiveMatch
                {
                    Id            = matchId,
                    Team1         = matchInfo.Team1,
                    Team2         = matchInfo.Team2,
                    State         = (QueryStack.MatchState)matchInfo.State,
                    IsBallInPlay  = matchInfo.IsBallInPlay,
                    TotalGoals1   = matchInfo.CurrentScore.TotalGoals1,
                    TotalGoals2   = matchInfo.CurrentScore.TotalGoals2,
                    CurrentPeriod = matchInfo.CurrentPeriod,
                    TimeInPeriod  = 0
                };
                _dbContext.Matches.Add(liveMatch);
            }
            else
            {
                lm.State         = (QueryStack.MatchState)matchInfo.State;
                lm.IsBallInPlay  = matchInfo.IsBallInPlay;
                lm.TotalGoals1   = matchInfo.CurrentScore.TotalGoals1;
                lm.TotalGoals2   = matchInfo.CurrentScore.TotalGoals2;
                lm.CurrentPeriod = matchInfo.CurrentPeriod;
                lm.TimeInPeriod  = 0;
            }
            _dbContext.SaveChanges();
        }
示例#3
0
 public MatchViewModel(CommandStack.Match m)
 {
     CurrentMatch = m;
 }