Example #1
0
        public HitterPlayerSeasonViewModel GetPlayerSeasonHittingStats(int season, int playerId, string leagueListId, string gameType)
        {
            string jsonData = this.GetSeasonHittingStatsJson(season, playerId, leagueListId, gameType);

            try
            {
                GetPlayerSeasonHittingSingleTeamStatsDTO dto = GetPlayerSeasonHittingSingleTeamStatsDTO.FromJson(jsonData);
                return(GetPlayerSeasonHittingSingleTeamViewModelFromDTO(dto));
            }
            catch (JsonSerializationException)
            {
                try
                {
                    GetPlayerSeasonHittingMultiTeamStatsDTO dto = GetPlayerSeasonHittingMultiTeamStatsDTO.FromJson(jsonData);
                    return(GetPlayerSeasonHittingMultiTeamViewModelFromDTO(dto));
                }
                catch
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                return(null);
            }
        }
Example #2
0
        private static HitterPlayerSeasonViewModel GetPlayerSeasonHittingSingleTeamViewModelFromDTO(GetPlayerSeasonHittingSingleTeamStatsDTO dto)
        {
            HitterPlayerSeasonViewModel returnVal = new HitterPlayerSeasonViewModel();

            if (dto != null && dto.sport_hitting_tm != null && dto.sport_hitting_tm.queryResults != null && dto.sport_hitting_tm.queryResults.row != null)
            {
                var playerStats = dto.sport_hitting_tm.queryResults.row;
                PopulateBattingStats(returnVal, playerStats);
            }

            return(returnVal);
        }