private void GenerateTourResults() { int?leagueId = League?.Id; if (Tour != null) { GamesInTour.GenerateResults(); using (var repository = new GameRepository(DatabaseSourceDefinitor.ConnectionString)) { repository.UpdateGames(GamesInTour); } using (var repository = new LeagueRepository(DatabaseSourceDefinitor.ConnectionString)) { Leagues = repository.GetLeagues(); } League = Leagues.FirstOrDefault(t => t.Id == leagueId); Tour = League.Tours.FirstOrDefault(t => t.Id == Tour.Id); using (var repository = new GameRepository(DatabaseSourceDefinitor.ConnectionString)) { GamesInTour = repository.GetGamesInTour(Tour.Id); } League.Calculate(); TeamsStat = League.TeamStats; } }
private void ShowNextSeason() { int indexOfLeague = Array.IndexOf(Leagues, League); IndexCarer.Increment(ref indexOfLeague, Leagues.Length - 1); if (Leagues.Length > 0) { League = Leagues[indexOfLeague]; Tour = League.Tours[0]; using (var repository = new GameRepository(DatabaseSourceDefinitor.ConnectionString)) { GamesInTour = repository.GetGamesInTour(Tour.Id); } League.Calculate(); TeamsStat = League.TeamStats; } }
private void InitializeData() { DatabaseSourceDefinitor.CreateDatabaseIfNotExist(); DatabaseSchemaUpdater.Update(); using (var repository = new LeagueRepository(DatabaseSourceDefinitor.ConnectionString)) { Leagues = repository.GetLeagues(); } if (Leagues.Length > 0) { int lastSeason = Leagues.Max(t => t.Season); League = Leagues.First(t => t.Season == lastSeason); Tour = League.Tours[0]; using (var repository = new GameRepository(DatabaseSourceDefinitor.ConnectionString)) { GamesInTour = repository.GetGamesInTour(Tour.Id); } League.Calculate(); TeamsStat = League.TeamStats; } }
private void GenerateSchedule() { int lastSeasonNumber = Leagues.Length == 0 ? 0 : Leagues.Max(t => t.Season); new LeagueModel().GenerateSeason(lastSeasonNumber + 1); using (var repository = new LeagueRepository(DatabaseSourceDefinitor.ConnectionString)) { Leagues = repository.GetLeagues(); } if (Leagues.Length > 0) { int lastSeason = Leagues.Max(t => t.Season); League = Leagues.First(t => t.Season == lastSeason); Tour = League.Tours[0]; using (var repository = new GameRepository(DatabaseSourceDefinitor.ConnectionString)) { GamesInTour = repository.GetGamesInTour(Tour.Id); } League.Calculate(); TeamsStat = League.TeamStats; } }