示例#1
0
        private void SendGameSummary(JObject gameObj)
        {
            List <string> result = new List <string>();

            var api = new NHLApiClient();

            var teamId       = _config.Team;
            var scheduleData = api.GetTodaysSchedule(teamId);
            var nextGame     = api.GetNextGame(teamId);
            var teamData     = api.GetTeam(teamId);

            _channel.SendMessageAsync(NHLInformationSummarizer.GameSummary(scheduleData, nextGame, teamData));
        }
示例#2
0
        public void GetNextGameTestBasic()
        {
            NHLApiClient api = new NHLApiClient();

            var testResponse = File.ReadAllText(@"../../../TestAPIResponses/GetNextGameResult.json");
            var jobj         = JObject.Parse(testResponse);
            var teamArray    = (JArray)jobj["teams"];
            var teamDetail   = JsonConvert.DeserializeObject <TeamDetail>(teamArray[0].ToString());
            var expected     = teamDetail.NextGameSchedule;

            // Make API web call
            GameScheduleData actual = api.GetNextGame(52); // Jets

            //Assert
            Assert.AreEqual(expected, actual);
        }
示例#3
0
        private IEnumerable <string> NextGame(int team)
        {
            List <string> result   = new List <string>();
            NHLApiClient  api      = new NHLApiClient();
            var           nextGame = api.GetNextGame(team);
            var           teamData = api.GetTeam(team);

            if (nextGame.TotalGames < 1)
            {
                result.Add(string.Format("There are currently no games scheduled for the {0}", teamData.Name));
                return(result);
            }

            result.Add(NHLInformationSummarizer.NextGameSummary(nextGame, teamData));
            return(result);
        }
        private IEnumerable <string> Countdown(string team)
        {
            Locator.Instance.Fetch <ILogger>().LogLine("Executing Countdown command for: " + team);
            List <string> result = new List <string>();
            int           teamId = -1;

            var isTeamId = int.TryParse(team, out teamId);

            if (!isTeamId)
            {
                var Ids = Locator.Instance.Fetch <TeamNameTranslator>().LookupIdsForName(team);
                if (Ids.Count > 1)
                {
                    result.Add("Name conflict, got more than one team ID for " + team + ". Please be more specific.");
                    return(result);
                }

                if (Ids.Count == 0)
                {
                    result.Add("Couldn't find a team by the name " + team + ". Please try another name.");
                    return(result);
                }

                teamId = Ids.First().Key;
            }

            var api      = new NHLApiClient();
            var nextGame = api.GetNextGame(teamId);
            var teamData = api.GetTeam(teamId);

            var timeToGame = nextGame.Dates.First().Games.First().GameDate - DateTime.UtcNow;

            if (timeToGame.Ticks <= 0)
            {
                result.Add(string.Format("The {0} are currently playing!", teamData.Name));
                return(result);
            }

            var formatString = (timeToGame.Days > 0 ? @"d\.h" : "") + @"h\:mm\:ss";

            result.Add(string.Format("The next {0} game is in {1}.", teamData.Name, timeToGame.Duration().ToString(formatString)));
            return(result);
        }
        private IEnumerable <string> NextGame(string team)
        {
            Locator.Instance.Fetch <ILogger>().LogLine("Executing NextGame command for team: " + team);
            List <string> result = new List <string>();
            NHLApiClient  api    = new NHLApiClient();
            int           teamId = -1;

            var isTeamId = int.TryParse(team, out teamId);

            if (!isTeamId)
            {
                var Ids = Locator.Instance.Fetch <TeamNameTranslator>().LookupIdsForName(team);
                if (Ids.Count > 1)
                {
                    result.Add("Name conflict, got more than one team ID for " + team + ". Please be more specific.");
                    return(result);
                }

                if (Ids.Count == 0)
                {
                    result.Add("Couldn't find a team by the name " + team + ". Please try another name.");
                    return(result);
                }

                teamId = Ids.First().Key;
            }

            var nextGame = api.GetNextGame(teamId);
            var teamData = api.GetTeam(teamId);

            if (nextGame.TotalGames < 1)
            {
                result.Add(string.Format("There are currently no games scheduled for the {0}", teamData.Name));
                return(result);
            }

            result.Add(NHLInformationSummarizer.NextGameSummary(nextGame, teamData));
            return(result);
        }