private void AddGoalieRows(TeamInfo team, HtmlNode row) { var rowValues = row.Descendants("td").Select(a => a.InnerText).ToList(); var nameValue = rowValues.ElementAt(0); var nameAcronyms = nameValue.GetAcronymns(); var goalieRow = new GoalieRow() { Name = Helper.GetName(nameValue), TeamAcronym = Helper.GetTeamAcronym(nameAcronyms), }; Helper.GetPlayerTeam(team.Acronym, nameAcronyms, goalieRow); goalieRow.Stats = Helper.GetStats(rowValues, goalieSkipColumns); goalieRow.Stats.Add(Helper.GetPenaltyShotsSaved(rowValues[15], goalieRow.Stats.ElementAt(12))); season.GoalieRows.Add(goalieRow); }
private Goalie GetGoalieFromRow(Goalie previousGoalie, GoalieRow goalieRow) { Goalie dbGoalie = null; if (previousGoalie.Name == goalieRow.Name) { dbGoalie = previousGoalie; } if (dbGoalie == null) { dbGoalie = db.Goalies.FirstOrDefault(a => a.Name == goalieRow.Name); } if (dbGoalie == null) { dbGoalie = new Goalie() { Name = goalieRow.Name }; db.Goalies.Add(dbGoalie); } return(dbGoalie); }
private void ExtractGoaliesFromSection(TeamInfo team, IList <string> goalieLines) { foreach (string line in goalieLines) { var nameValue = line.Substring(0, 30).Replace("_", "").Trim(); var nameAcronyms = nameValue.GetAcronymns(); GoalieRow goalieRow = new GoalieRow() { Name = Helper.GetName(nameValue), TeamAcronym = Helper.GetTeamAcronym(nameAcronyms) }; Helper.GetPlayerTeam(team.Acronym, nameAcronyms, goalieRow); string rawStatsLine = line.Substring(30, line.Length - 30).Replace("%", "").Trim(); string[] rawStats = rawStatsLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); goalieRow.Stats = Helper.GetStats(rawStats, goalieSkipColumns); goalieRow.Stats.Add(Helper.GetPenaltyShotsSaved(rawStats[14], goalieRow.Stats.ElementAt(11))); season.GoalieRows.Add(goalieRow); } }