public override async Task <IEnumerable <IGenericTournamentCoupon> > GetTournaments(OddsDownloadStage stage = OddsDownloadStage.Tournament) { var tournamentsReturn = new List <IGenericTournamentCoupon>(); var webRepository = this.webRepositoryProvider .CreateWebRepository(this.valueOptions.CouponDate); var html = await webRepository.GetHTML(this.bookmakerRepository.GetTournamentCouponUrl(this.valueOptions.Tournament, this.valueOptions.OddsSource)); var oddscheckerCompetitions = WebUtils.ParseWebsite <TCompetition>(html, s => { }) .Cast <TCompetition>() .Where(c => c.CompetitionType == this.valueOptions.Tournament.TournamentName) .ToList(); foreach (var t in oddscheckerCompetitions) { var competetion = new GenericTournamentCoupon() { TournamentName = t.CompetitionName, TournamentURL = t.CompetitionURL, }; if (stage != OddsDownloadStage.Tournament) { var matchesToAdd = new List <GenericMatchCoupon>(); matchesToAdd.AddRange(await GetMatches(t.CompetitionURL)); competetion.Matches = matchesToAdd; } tournamentsReturn.Add(competetion); } return(tournamentsReturn); }
public override IEnumerable <IGenericTournamentCoupon> GetTournaments(OddsDownloadStage stage = OddsDownloadStage.Tournament) { var tournamentsReturn = new List <IGenericTournamentCoupon>(); var webRepository = this.webRepositoryProvider.CreateWebRepository(this.valueOptions.CouponDate); var html = webRepository.GetHTML(new[] { this.bookmakerRepository.GetTournamentCouponUrl(this.valueOptions.Tournament, this.valueOptions.OddsSource) }, s => ProgressReporterProvider.Current.ReportProgress(s, ReporterImportance.Low, ReporterAudience.Admin), string.Format("{0} OddsChecker Coupon", this.valueOptions.CouponDate.ToShortDateString())) .First(); var oddscheckerCompetitions = WebUtils.ParseWebsite <TCompetition>(html, s => ProgressReporterProvider.Current.ReportProgress(s, ReporterImportance.Low, ReporterAudience.Admin)) .Cast <TCompetition>() .Where(c => c.CompetitionType == this.valueOptions.Tournament.TournamentName) .ToList(); foreach (var t in oddscheckerCompetitions) { var competetion = new GenericTournamentCoupon() { TournamentName = t.CompetitionName, TournamentURL = t.CompetitionURL, }; if (stage != OddsDownloadStage.Tournament) { var matchesToAdd = new List <GenericMatchCoupon>(); matchesToAdd.AddRange(GetMatches(t.CompetitionURL)); competetion.Matches = matchesToAdd; } tournamentsReturn.Add(competetion); } return(tournamentsReturn); }
public override async Task <IEnumerable <IGenericTournamentCoupon> > GetTournaments(OddsDownloadStage stage = OddsDownloadStage.Tournament) { var competitionsReturn = new List <IGenericTournamentCoupon>(); var webRepository = this.webRepositoryProvider .CreateWebRepository(this.valueOptions.CouponDate); var html = await webRepository.GetHTML(this.bookmakerRepository.GetTournamentCouponUrl(this.valueOptions.Tournament, this.valueOptions.OddsSource), string.Format("{0} BestBetting Coupon", this.valueOptions.CouponDate.ToShortDateString())); var bestbettingCompetitions = WebUtils.ParseWebsite <TCompetition>(html, s => { }) .Cast <TCompetition>() .Where(c => c.CompetitionType == this.valueOptions.Tournament.TournamentName) .ToList(); foreach (var t in bestbettingCompetitions) { if (competitionsReturn.Count(tMain => tMain.TournamentName == t.CompetitionName) != 0) { continue; //guard against repetition on BestBetting tennis } var tournament = new GenericTournamentCoupon { TournamentName = t.CompetitionName, TournamentURL = t.CompetitionURL, }; if (stage != OddsDownloadStage.Tournament) { var matchesToAdd = new List <GenericMatchCoupon>(); matchesToAdd.AddRange(await GetMatches(t.CompetitionURL)); tournament.Matches = matchesToAdd; } competitionsReturn.Add(tournament); } return(competitionsReturn); }