public async Task <MonthlyGameResultsData> GetSchedule(Season season, Month month) { var document = await _documentLoader.LoadDocument(_settings.ToDocumentOptions(season, month)); var gameResults = _gameResultsParser.Parse(document); return(new MonthlyGameResultsData(gameResults)); }
public async Task <GameDetailsData> GetGameDetails(Season season, BoxScoreLink boxScoreLink) { var document = await _documentLoader.LoadDocument(_settings.ToDocumentOptions(season, boxScoreLink)); var lineScore = _lineScoreParser.Parse(document); var homeBoxScore = _teamBoxScoreParser.Parse(document, lineScore.HomeTeam); var visitorBoxScore = _teamBoxScoreParser.Parse(document, lineScore.VisitorTeam); return(new GameDetailsData(lineScore.HomeTeam, lineScore.VisitorTeam, boxScoreLink.GameDate, boxScoreLink.GameId, lineScore, homeBoxScore, visitorBoxScore)); }
public async Task <IDocument> LoadDocument(DocumentOptions options) { var document = await _next.LoadDocument(options); _fileSystem.CreateDirectory(options.DirectoryPath); await _fileSystem.CreateFile(options.FilePath, new FileContent(options.Url, options.FilePath, document.Source.Text)); return(document); }
public async Task <IDocument> LoadDocument(DocumentOptions options) { var document = await _next.LoadDocument(options); if (!document.IsSuccessStatusCode()) { throw new HttpRequestException($"Request for url = '{document.Url}' returned status code = '{document.StatusCode}'"); } return(document); }
public async Task <TeamData> GetTeamData(Team team, Season season) { var document = await _documentLoader.LoadDocument(_settings.ToDocumentOptions(team, season)); var rooster = _teamRoosterParser.Parse(document); var playerSeasonStatistics = _playerSeasonStatisticsParser.Parse(document); var playByPlay = _playByPlayParser.Parse(document); var teamMisc = _teamMiscParser.Parse(document); return(new TeamData(teamMisc, rooster, playerSeasonStatistics, playByPlay)); }
public async Task <IDocument> LoadDocument(DocumentOptions options) { if (!_fileSystem.FileExists(options.FilePath)) { return(await _next.LoadDocument(options)); } var fileContent = await _fileSystem.LoadFileContent(options.FilePath); return(await _browsingContext.OpenAsync(request => { request.Address(options.Url); request.Content(fileContent.Content); request.Status(HttpStatusCode.OK); })); }