Exemplo n.º 1
0
        public async Task <SeasonalPlayerGameLog> GetSeasonPlayerGameLog(string season)
        {
            SetUpClient();

            string url = BasePullUrl + season + "/player_gamelogs.json";

            try
            {
                HttpResponseMessage response = await client.GetAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    var jsonString = await response.Content.ReadAsStringAsync();

                    SeasonalPlayerGameLog games = JsonConvert.DeserializeObject <SeasonalPlayerGameLog>(jsonString);

                    foreach (var game in games.GameLogs)
                    {
                        //Console.Write(game.Game..HomeTeam.Abbreviation + " (" + game.Score.HomeScoreTotal + ") -" + game.Schedule.AwayTeam.Abbreviation + " (" + game.Score.AwayScoreTotal + ") \r");
                    }

                    return(games);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
Exemplo n.º 2
0
        public async Task <SeasonalPlayerGameLog> GetDailyPlayerGameLog(string season, DateTime date)
        {
            SetUpClient();

            string url = BasePullUrl + season + "/date/" + date.ToString("yyyyMMdd") + "/player_gamelogs.json";

            try
            {
                HttpResponseMessage response = await client.GetAsync(url);

                if (response.IsSuccessStatusCode)
                {
                    var jsonString = await response.Content.ReadAsStringAsync();

                    SeasonalPlayerGameLog games = JsonConvert.DeserializeObject <SeasonalPlayerGameLog>(jsonString);
                    Console.Write("On " + date.ToShortDateString() + " here's what everyone did in the NBA: \r");
                    foreach (var game in games.GameLogs)
                    {
                        Console.Write(game.Player.FirstName + " " + game.Player.LastName + " (" + game.Team.Abbreviation + ") had " + game.Stats.Offense.pts + " points, " + game.Stats.Offense.ast + " assists, and " + game.Stats.Rebounds.reb + " rebounds \r");
                    }

                    return(games);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Index()
        {
            SportsFeedAPI.ScheduleService scheduleService = new SportsFeedAPI.ScheduleService();
            SportsFeedAPI.PlayerService   playerService   = new SportsFeedAPI.PlayerService();


            //DailyGames dailyGames = await scheduleService.GetDailyGames("2018-2019-regular", "20181027");
            //GetSeasonSchedule seasonGames = await scheduleService.GetSeasonSchedule("2018-2019-regular");
            SeasonalPlayerGameLog gameLog = await playerService.GetDailyPlayerGameLog("2017-2018-regular", DateTime.Now.AddYears(-1).AddDays(-1));

            string literal = "";

            //foreach (var game in seasonGames.Games)
            //{
            //    literal += game.Schedule.AwayTeam.Abbreviation + " at " + game.Schedule.HomeTeam.Abbreviation + "      /       ";
            //}

            results = literal;
            return(RedirectToAction("HomePage"));
        }