private static PitcherPlayerSeasonViewModel GetPlayerSeasonPitchingSingleTeamViewModelFromDTO(GetPlayerSeasonPitchingSingleTeamStatsDTO dto) { PitcherPlayerSeasonViewModel returnVal = new PitcherPlayerSeasonViewModel(); if (dto != null && dto.sport_pitching_tm != null && dto.sport_pitching_tm.queryResults != null && dto.sport_pitching_tm.queryResults.row != null) { var playerStats = dto.sport_pitching_tm.queryResults.row; PopulatePitchingStats(returnVal, playerStats); } return(returnVal); }
private static void PopulatePitchingStats(PitcherPlayerSeasonViewModel returnVal, PitchingStat playerStats) { returnVal.Wins = !playerStats.w.Contains("-") ? Convert.ToInt32(playerStats.w) : 0; returnVal.Losses = !playerStats.l.Contains("-") ? Convert.ToInt32(playerStats.l) : 0; returnVal.ERA = !playerStats.era.Contains("-") ? Convert.ToDecimal(playerStats.era) : 0; returnVal.WHIP = !playerStats.whip.Contains("*") ? Convert.ToDecimal(playerStats.whip) : 0; returnVal.Player = new PlayerViewModel { Id = Convert.ToInt32(playerStats.player_id) }; }
private static PitcherPlayerSeasonViewModel GetPlayerSeasonPitchingMultiTeamViewModelFromDTO(GetPlayerSeasonPitchingMultiTeamStatsDTO dto) { PitcherPlayerSeasonViewModel returnVal = new PitcherPlayerSeasonViewModel(); if (dto != null && dto.sport_pitching_tm != null && dto.sport_pitching_tm.queryResults != null && dto.sport_pitching_tm.queryResults.row != null) { foreach (PitchingStat playerStats in dto.sport_pitching_tm.queryResults.row) { PopulatePitchingStats(returnVal, playerStats); } } return(returnVal); }