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(); } }
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(); } }
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); } } }
public MatchControllerService(IEventRepository eventRepository, WaterpoloContext dbContext) { _eventRepository = eventRepository; _dbContext = dbContext; }
public LiveControllerService(WaterpoloContext dbContext) { _dbContext = dbContext; }