Esempio n. 1
0
        private void UpdateSnapshots(String matchId)
        {
            var repo      = new EventRepository();
            var events    = repo.GetEventStreamFor(matchId);
            var matchInfo = EventHelper.PlayEvents(matchId, events.ToList());

            using (var db = new WaterpoloContext())
            {
                var lm = (from m in db.Matches where m.Id == matchId select m).FirstOrDefault();
                if (lm == null)
                {
                    var liveMatch = new LiveMatch
                    {
                        Id            = matchId,
                        Team1         = matchInfo.Team1,
                        Team2         = matchInfo.Team2,
                        State         = matchInfo.State,
                        IsBallInPlay  = matchInfo.IsBallInPlay,
                        CurrentScore  = matchInfo.CurrentScore,
                        CurrentPeriod = matchInfo.CurrentPeriod,
                        TimeInPeriod  = 0
                    };
                    db.Matches.Add(liveMatch);
                }
                else
                {
                    lm.State         = matchInfo.State;
                    lm.IsBallInPlay  = matchInfo.IsBallInPlay;
                    lm.CurrentScore  = matchInfo.CurrentScore;
                    lm.CurrentPeriod = matchInfo.CurrentPeriod;
                    lm.TimeInPeriod  = 0;
                }
                db.SaveChanges();
            }
        }
Esempio n. 2
0
 private void ZapSnapshots(String matchId)
 {
     using (var db = new WaterpoloContext())
     {
         var lm = (from m in db.Matches where m.Id == matchId select m).FirstOrDefault();
         if (lm != null)
         {
             db.Matches.Remove(lm);
         }
         db.SaveChanges();
     }
 }
Esempio n. 3
0
     public LiveMatch GetLiveMatch(String matchId)
     {
         using (var db = new WaterpoloContext())
         {
             var lm = (from m in db.Matches where m.Id == matchId select m).FirstOrDefault();
             if (lm == null)
             {
                 return new LiveMatch()
                        {
                            Id = matchId
                        }
             }
             ;
             return(lm);
         }
     }
 }
Esempio n. 4
0
 public MatchControllerService(IEventRepository eventRepository, WaterpoloContext dbContext)
 {
     _eventRepository = eventRepository;
     _dbContext       = dbContext;
 }
 public LiveControllerService(WaterpoloContext dbContext)
 {
     _dbContext = dbContext;
 }