Ejemplo n.º 1
0
        public PitcherPlayerSeasonViewModel GetPlayerSeasonPitchingStats(int season, int playerId, string leagueListId, string gameType)
        {
            string jsonData = this.GetSeasonPitchingStatsJson(season, playerId, leagueListId, gameType);

            try
            {
                GetPlayerSeasonPitchingSingleTeamStatsDTO dto = GetPlayerSeasonPitchingSingleTeamStatsDTO.FromJson(jsonData);
                return(GetPlayerSeasonPitchingSingleTeamViewModelFromDTO(dto));
            }
            catch (Newtonsoft.Json.JsonSerializationException)
            {
                try
                {
                    GetPlayerSeasonPitchingMultiTeamStatsDTO dto = GetPlayerSeasonPitchingMultiTeamStatsDTO.FromJson(jsonData);
                    return(GetPlayerSeasonPitchingMultiTeamViewModelFromDTO(dto));
                }
                catch
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        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);
        }