public void Get(DefenseLogs defenses, string gameid) { try { Dictionary <string, string> values = new Dictionary <string, string>() { { "@game", gameid } }; List <string[]> results = SelectProc("GetAllDefensesStatsGame", values); Defense defense = null; DefenseGameStats gameStats = null; foreach (string[] result in results) { if (defense == null || defense.defense.abbr != result[0]) { if (defense != null) { defenses.defenseLogs.Add(defense); } defense = new Defense(); defense.gameLogs = new List <DefenseGameStats>(); defense.defense.abbr = result[0]; defense.defense.city = result[1]; defense.defense.name = result[2]; } gameStats = new DefenseGameStats(); gameStats.game.gameid = result[3]; gameStats.game.date = result[4]; gameStats.game.time = result[5]; gameStats.game.homeTeam.abbr = result[6]; gameStats.game.homeTeam.city = result[7]; gameStats.game.homeTeam.name = result[8]; gameStats.game.awayTeam.abbr = result[9]; gameStats.game.awayTeam.city = result[10]; gameStats.game.awayTeam.name = result[11]; gameStats.stats.pa = result[12]; gameStats.stats.sck = result[13]; gameStats.stats.fum = result[14]; gameStats.stats.intc = result[15]; gameStats.stats.intTd = result[16]; gameStats.stats.fumTd = result[17]; gameStats.stats.sfty = result[18]; gameStats.stats.krTd = result[19]; gameStats.stats.prTd = result[20]; gameStats.stats.fgBlk = result[21]; gameStats.stats.xpBlk = result[22]; defense.gameLogs.Add(gameStats); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public void Get(Defense defense) { try { Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("@Team", defense.defense.abbr); DefenseGameStats gameStats; List <string[]> results = SelectProc("GetDefenseGameLogs", values); defense.gameLogs = new List <DefenseGameStats>(); defense.defense.abbr = results[0][0]; defense.defense.city = results[0][1]; defense.defense.name = results[0][2]; foreach (string[] result in results) { gameStats = new DefenseGameStats(); gameStats.game.gameid = result[3]; gameStats.game.date = result[4]; gameStats.game.time = result[5]; gameStats.game.homeTeam.abbr = result[6]; gameStats.game.homeTeam.city = result[7]; gameStats.game.homeTeam.name = result[8]; gameStats.game.awayTeam.abbr = result[9]; gameStats.game.awayTeam.city = result[10]; gameStats.game.awayTeam.name = result[11]; gameStats.stats.pa = result[12]; gameStats.stats.sck = result[13]; gameStats.stats.fum = result[14]; gameStats.stats.intc = result[15]; gameStats.stats.intTd = result[16]; gameStats.stats.fumTd = result[17]; gameStats.stats.sfty = result[18]; gameStats.stats.krTd = result[19]; gameStats.stats.prTd = result[20]; gameStats.stats.fgBlk = result[21]; gameStats.stats.xpBlk = result[22]; defense.gameLogs.Add(gameStats); } } catch (Exception e) { throw new Exception(e.Message, e); } }
/// <summary> /// Gets defensive game statistics of a specified NFL team /// </summary> /// <param name="team">Contains specific team abbreviation (i.e. NYG for New York Giants)</param> /// <returns></returns> public List <Defense> GetGameStats() { List <Team> teams = new TeamRequest(new Season(season.year, season.playoffs)).GetTeams(); List <Defense> defenses = new List <Defense>(); foreach (Team team in teams) { Thread.Sleep(10000); string DefGames = "/team_gamelogs.json?team=" + team.abbr; JArray allGames = (JArray)JObject.Parse(Submit(DefGames))["teamgamelogs"]["gamelogs"]; Team currentTeam = team; Game currentGame; DefenseStats currentStats; DefenseGameStats currentGameStats; Defense currentDefense = new Defense(currentTeam.abbr, new List <DefenseGameStats>()); foreach (JToken game in allGames) { currentGame = new Game((string)game["game"]["id"]); currentStats = new DefenseStats(); currentStats.pa = (string)game["stats"]["PointsAgainst"]["#text"]; currentStats.sck = (string)game["stats"]["Sacks"]["#text"]; currentStats.fum = (string)game["stats"]["FumForced"]["#text"]; currentStats.intc = (string)game["stats"]["Interceptions"]["#text"]; currentStats.intTd = (string)game["stats"]["IntTD"]["#text"]; currentStats.fumTd = (string)game["stats"]["FumTD"]["#text"]; currentStats.sfty = (string)game["stats"]["Safeties"]["#text"]; currentStats.krTd = (string)game["stats"]["KrTD"]["#text"]; currentStats.prTd = (string)game["stats"]["PrTD"]["#text"]; currentStats.fgBlk = (string)game["stats"]["FgBlk"]["#text"]; currentStats.xpBlk = (string)game["stats"]["XpBlk"]["#text"]; currentGameStats = new DefenseGameStats(currentGame, currentStats); currentDefense.gameLogs.Add(currentGameStats); } defenses.Add(currentDefense); } Thread.Sleep(10000); return(defenses); }