// PRIMARY METHODS offers 3 options to instantiate a new yahoo stats model
        // OPTION 1 - endpoint parameters defined within the method
        // OPTION 2 - endpoint parameters passed as parameters to method
        // OPTION 3 - endpoint parameters are appended to the Url


        // OPTION 1: endpoint parameters defined within the method
        // STATUS [ June 9, 2019 ] : this works
        /// <summary>
        ///     Create new instance of YahooTeamStats Model
        ///     Show full season stats for one team
        /// </summary>
        /// <remarks>
        ///     This is the least helpful option of the method
        ///     Within Option 1, the 'teamId' is defined within the method itself
        ///     To change the team Id you're searching for, change the 'teamId' variable;
        ///     Includes: H/AB, R, HR, RBI, SB, BB, IP, W, SV, H, ERA, WHIP
        ///     Relies on 'PopulateTeamStatsProperties()' to populate model properties
        /// </remarks>
        /// <example>
        ///     https://127.0.0.1:5001/api/yahoo/teamstats
        /// </example>
        /// <returns>
        ///     New YahooTeamStatsModel
        /// </returns>
        public YahooTeamStatsList CreateYahooTeamStatsModel()
        {
            // _h.Spotlight("executing create yahoo team stats method option 1");
            const int teamId      = 1;
            string    leagueKey   = _yahooApiRequestController.GetTheGameIsTheGameLeagueKey();
            string    uriTeamBase = endPoints.TeamSeasonStatsEndPoint(leagueKey, teamId).EndPointUri;

            JObject teamStatsJson = _yahooApiRequestController.GenerateYahooResourceJObject(uriTeamBase);

            YahooTeamStatsList tS = PopulateTeamStatsProperties(teamStatsJson);

            _helpers.Dig(tS);
            return(tS);
        }
예제 #2
0
        // 1 : DJB
        // 2 : DSch
        // 3 : CSt
        // 4 : SpMc
        // 5 : PJB
        // 6 : JB
        // 7 : Pants
        // 8 : JCuz
        // 9 : DBra
        // 10: MC

        #region YAHOO MANAGER - PRIMARY METHODS ------------------------------------------------------------


        // STATUS [ June 8, 2019 ] : this works
        /// <summary>
        ///     Instantiate new instance of a yahoo manager
        ///     The manager data in the requested json is found nested under league standings
        /// </summary>
        /// <param name="managerId">
        ///     A number 0 - X; Where X is the total number of teams in the league;
        ///     Basically every manager has their own single number Id;
        ///     Select the Id of the Manager you would want to view
        /// </param>
        /// <example>
        ///     var yahooManager = CreateYahooManagerModel(1);
        /// </example>
        /// <returns>
        ///     A new YahooManager
        /// </returns>
        public YahooManager CreateYahooManagerModel(int managerId)
        {
            // _h.StartMethod();
            string leagueKey = _yahooApiRequestController.GetTheGameIsTheGameLeagueKey();
            // Console.WriteLine($"MANAGER CONTROLLER > leagueKey: {leagueKey}");

            // Create the uri that will be used to generate the appropriate json
            // Use Lg. Standings endpoint because mgr. details are nested in league standings json
            var uriLeagueStandings = _endPoints.LeagueStandingsEndPoint(leagueKey).EndPointUri;

            JObject leagueStandings = _yahooApiRequestController.GenerateYahooResourceJObject(uriLeagueStandings);

            YahooManager yM = new YahooManager
            {
                // these pull from the yahoo response (xml or json) to set each item
                ManagerId = _endPoints.TeamItem(leagueStandings, managerId, "ManagerId"),
                NickName  = _endPoints.TeamItem(leagueStandings, managerId, "Nickname"),
                Guid      = _endPoints.TeamItem(leagueStandings, managerId, "Guid"),
            };

            // Only the commish of the league will have  the "IsCommissioner" field
            try { yM.IsCommissioner = _endPoints.TeamItem(leagueStandings, managerId, "IsCommissioner"); }
            catch (Exception ex) { Console.WriteLine("ERROR IN: YahooManagerController.CreateYahooManagerModel() --> user not the commish"); }


            // "IsCurrentLogin" will only return data of current user is fetching their league's data
            try { yM.IsCurrentLogin = _endPoints.TeamItem(leagueStandings, managerId, "IsCurrentLogin"); }
            catch (Exception ex)
            { Console.WriteLine("ERROR IN: YahooManagerController.CreateYahooManagerModel() --> user not looged in "); }


            // Yahoo managers can hide their email; if hidden, you'll get an error
            try { yM.Email = _endPoints.TeamItem(leagueStandings, managerId, "Email"); }
            catch (Exception ex)
            { Console.WriteLine("ERROR IN: YahooManagerController.CreateYahooManagerModel() --> User has no email"); }

            yM.ImageUrl = _endPoints.TeamItem(leagueStandings, managerId, "ImageUrl");
            // PrintYahooManagerDetails(yM);
            return(yM);
        }
        // TO-DO: add XML summary comments
        // Step 1
        public void CreateYahooLeagueScoreboard()
        {
            _h.StartMethod();

            // retrieve the league key from user secrets / yahoo league config
            string leagueKey = _yahooApiRequestController.GetTheGameIsTheGameLeagueKey();

            string uriLeagueScoreboard = endPoints.LeagueSeasonScoreboardEndPoint(leagueKey).EndPointUri;

            JObject leagueScoreboard = _yahooApiRequestController.GenerateYahooResourceJObject(uriLeagueScoreboard);

            _h.PrintJObjectItems(leagueScoreboard);
        }