private IEnumerable <string> LastGameLineScore(int teamId) { List <string> result = new List <string>(); var api = new NHLApiClient(); var lastGame = api.GetLastGame(teamId); var teamData = api.GetTeam(teamId); if (lastGame == null || lastGame.TotalGames < 1) { result.Add(string.Format("There are currently no previous games the {0}", teamData.Name)); return(result); } var homeTeam = api.GetTeam(lastGame.Dates[0].Games[0].Teams.Home.Team.Id); var awayTeam = api.GetTeam(lastGame.Dates[0].Games[0].Teams.Away.Team.Id); var gameData = api.GetLiveGameDetail(lastGame.Dates[0].Games[0].GamePk); var lineScore = api.GetGameLineScore(lastGame.Dates[0].Games[0].GamePk); foreach (var period in lineScore.Periods) { var summary = NHLInformationSummarizer.PeriodSummary(period, homeTeam, awayTeam, gameData); result.Add(summary.ToString()); } return(result); }
private void SendLineScoreForPeriod(JObject gameObj) { List <string> result = new List <string>(); var api = new NHLApiClient(); var homeTeam = api.GetTeam(int.Parse(gameObj["gameData"]["teams"]["home"]["id"].ToString())); var awayTeam = api.GetTeam(int.Parse(gameObj["gameData"]["teams"]["away"]["id"].ToString())); var gameData = api.GetLiveGameDetail(int.Parse(gameObj["gamePk"].ToString())); var lineScore = api.GetGameLineScore(int.Parse(gameObj["gamePk"].ToString())); _channel.SendMessageAsync(NHLInformationSummarizer.PeriodSummary(lineScore.Periods.Last(), homeTeam, awayTeam, gameData)); }
private void SendLineScoreForPeriod(JObject gameObj) { List <string> result = new List <string>(); var api = new NHLApiClient(); var homeTeam = api.GetTeam(int.Parse(gameObj["gameData"]["teams"]["home"]["id"].ToString())); var awayTeam = api.GetTeam(int.Parse(gameObj["gameData"]["teams"]["away"]["id"].ToString())); var gameData = api.GetLiveGameDetail(int.Parse(gameObj["gamePk"].ToString())); var lineScore = api.GetGameLineScore(int.Parse(gameObj["gamePk"].ToString())); Locator.Instance.Fetch <ILogger>().LogLine(String.Format("Goal Horn: Sending period line score for {0}", _config.TeamFriendlyName)); _channel.SendMessageAsync(NHLInformationSummarizer.PeriodSummary(lineScore.Periods.Last(), homeTeam, awayTeam, gameData)); }
private IEnumerable <string> LastGameLineScore(string team) { Locator.Instance.Fetch <ILogger>().LogLine("Executing LastGameLineScore 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 lastGame = api.GetLastGame(teamId); var teamData = api.GetTeam(teamId); if (lastGame == null || lastGame.TotalGames < 1) { result.Add(string.Format("There are currently no previous games the {0}", teamData.Name)); return(result); } var homeTeam = api.GetTeam(lastGame.Dates[0].Games[0].Teams.Home.Team.Id); var awayTeam = api.GetTeam(lastGame.Dates[0].Games[0].Teams.Away.Team.Id); var gameData = api.GetLiveGameDetail(lastGame.Dates[0].Games[0].GamePk); var lineScore = api.GetGameLineScore(lastGame.Dates[0].Games[0].GamePk); foreach (var period in lineScore.Periods) { var summary = NHLInformationSummarizer.PeriodSummary(period, homeTeam, awayTeam, gameData); result.Add(summary.ToString()); } return(result); }