Exemple #1
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);
        }
Exemple #2
0
        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);
        }