public override void MigrateFixtures(int htSeriesId, int season) { var seriesFixturesResult = GetSeriesFixtures(season, htSeriesId); Session.Clear(); var repository = new SeriesRepository(Session); var series = repository.GetAll().First(s => s.HtSeriesId == htSeriesId); SetFixtures(series, season, seriesFixturesResult); using (var transaction = Session.BeginTransaction()) { repository.SaveUpdate(series); transaction.Commit(); } }
public override void MigrateMatchDetails(int matchId, int matchRound, int season, int htSeriesId) { var matchDetails = GetMatchDetails(matchId); Session.Clear(); var repository = new SeriesRepository(Session); var series = repository.GetAll().First(s => s.HtSeriesId == htSeriesId); var match = series.Matches.FirstOrDefault(m => m.MatchId == matchId); var htMatch = matchDetails.Match.First(); DateTime matchFinishDate; if (DateTime.TryParse(htMatch.FinishedDate, out matchFinishDate)) { var htAwayTeam = htMatch.AwayTeam.First(); var htHomeTeam = htMatch.HomeTeam.First(); if (match == null) { match = new Match { HtMatchId = int.Parse(htMatch.MatchID), MatchDate = DateTime.Parse(htMatch.MatchDate), FinishedDate = DateTime.Parse(htMatch.FinishedDate), MatchArena = new MatchArena { ArenaName = htMatch.MatchArena.ArenaName, HtArenaId = int.Parse(htMatch.MatchArena.ArenaID), WeatherId = short.Parse(htMatch.MatchArena.WeatherID) }, MatchType = short.Parse(htMatch.MatchType), MatchSeason = (short)season, MatchRound = (short)matchRound }; match.SetMatchHomeTeam(GetMatchTeam(series.Country, htHomeTeam, htMatch.PossessionFirstHalfHome, htMatch.PossessionSecondHalfHome)); match.SetMatchAwayTeam(GetMatchTeam(series.Country, htAwayTeam, htMatch.PossessionFirstHalfAway, htMatch.PossessionSecondHalfAway)); ProcessScorers(match, htMatch); ProcessInjuries(match, htMatch); ProcessBookings(match, htMatch); ProcessEvents(match, htMatch); series.AddMatch(match); } } repository.SaveUpdate(series); Session.Flush(); }