public List <Player> GetActualRoster( string teamSlug, DateTime queryDate, int gamesBack, bool battersOnly = false) { var result = new List <Player>(); for (int d = 0; d < gamesBack; d++) { var lineupDate = queryDate.AddDays(-d); var lineup = _lineupRepo.Submit( lineupDate, teamSlug); foreach (var player in lineup.Lineup) { if (battersOnly) { if (player.IsBatter()) { Player thisPlayer = CastToPlayer(player); AddPlayerIfNew(result, thisPlayer); } } else { Player thisPlayer = CastToPlayer(player); AddPlayerIfNew(result, thisPlayer); } } } return(result); }
private LineupViewModel BasicOpponentsLineup( Pitcher pitcher, DateTime lineupQueryDate) { var opponentTeam = pitcher.OpponentSlug; var result = _lineupRepository.Submit( queryDate: lineupQueryDate, teamSlug: opponentTeam); if (result.Lineup.Count.Equals(0)) { // go back one more day result = _lineupRepository.Submit( queryDate: lineupQueryDate.AddDays(-1), teamSlug: opponentTeam); } return(result); }
public LineupViewModel Submit(DateTime queryDate, string teamSlug) { var keyValue = $"lineup:{teamSlug}:{Utility.UniversalDate(queryDate)}"; if (!_cache.TryGet(keyValue, out LineupViewModel viewModel)) { viewModel = _decoratedComponent.Submit(queryDate, teamSlug); _cache.Set(keyValue, viewModel); } return(viewModel); }
private bool NotInLineup( DateTime gameDate, Batter batter) { if (batter == null || batter.TeamSlug == null) { return(true); } var lineup = _lineupRepository.Submit( gameDate, batter.TeamSlug).Lineup; if (!LineupHas(batter, lineup)) { return(true); } return(false); }