Beispiel #1
0
        public LeagueTable GetBySeasonAndCompetition(string seasonId, string competitionId)
        {
            SeasonCompetition seasonCompetition;
             using (var seasonCompetitionRepository = new RepositoryFactory().CreateSeasonCompetitionRepository())
             {
            seasonCompetition = seasonCompetitionRepository.Find(sc => sc.SeasonId == seasonId && sc.CompetitionId == competitionId).FirstOrDefault();
            if (seasonCompetition == null)
            {
               string message = $"Combination of season '{seasonId}' and competition '{competitionId}' does not exist";
               throw new NotFoundException(message);
            }
             }

             using (var leagueTableRepository = new RepositoryFactory().CreateLeagueTableRepository())
             {
            var leagueTable = leagueTableRepository.GetBySeasonCompetition(seasonCompetition.Id);
            if (leagueTable == null)
            {
               string message = $"No league table exists for season '{seasonId}' and competition '{competitionId}'";
               throw new NotFoundException(message);
            }

            return leagueTable;
             }
        }