public JbsBoxscore BuildBoxscore(MlbGameData gameData) { var boxscore = new JbsBoxscore(); var awayTeamBox = gameData.boxscore.teams.away; var homeTeamBox = gameData.boxscore.teams.home; boxscore.status = gameData.status; boxscore.gameDate = gameData.gameDate; boxscore.id = gameData.id; boxscore.awayLocationName = awayTeamBox.team.locationName; boxscore.homeLocationName = homeTeamBox.team.locationName; boxscore.awayTeamName = awayTeamBox.team.teamName; boxscore.homeTeamName = homeTeamBox.team.teamName; boxscore.awayShortName = awayTeamBox.team.shortName; boxscore.homeShortName = homeTeamBox.team.shortName; boxscore.fieldingAndBattingInfo = BuildFieldingAndBattingInfo(awayTeamBox.info, homeTeamBox.info); boxscore.pitchingAndGameInfo = gameData.boxscore.info.ToList(); boxscore.linescore = gameData.linescore; if (gameData.feedLive != null) { boxscore.homeBatters = BuildBatterList(homeTeamBox.batters, homeTeamBox.players.players, gameData.feedLive.gameData.players.players); boxscore.awayBatters = BuildBatterList(awayTeamBox.batters, awayTeamBox.players.players, gameData.feedLive.gameData.players.players); boxscore.homePitchers = BuildPitcherList(homeTeamBox.pitchers, homeTeamBox.players.players, gameData.feedLive.gameData.players.players); boxscore.awayPitchers = BuildPitcherList(awayTeamBox.pitchers, awayTeamBox.players.players, gameData.feedLive.gameData.players.players); } return(boxscore); }
private async Task <List <JbsBoxscore> > GetJbsBoxscores(IList <Game> games) { var boxscores = new List <JbsBoxscore>(); foreach (var game in games) { var gameData = new MlbGameData(); gameData.id = game.gamePk.ToString(); gameData.status = game.status; gameData.gameDate = game.gameDate; gameData.linescore = await _mlbApiService.GetGameLinescore(game.gamePk.ToString()); gameData.boxscore = await _mlbApiService.GetBoxscore(game.gamePk.ToString()); if (gameData.status.statusCode != MlbGameAbstractStatusCodes.Preview) { gameData.feedLive = await _mlbApiService.GetGameFeedLive(game.gamePk.ToString()); } boxscores.Add(_mlbService.BuildBoxscore(gameData)); } return(boxscores); }