private static Nhl_Games_Rtss MapHtmlRowToModel(HtmlNode row, NhlSeasonType nhlSeasonType) { HtmlNodeCollection tdNodes = row.SelectNodes(@"./td"); Nhl_Games_Rtss model = new Nhl_Games_Rtss(); model.NhlSeasonType = nhlSeasonType; model.Date = Convert.ToDateTime(tdNodes[0].InnerText.Replace("'", "/")); model.Year = NhlModelHelper.GetSeason(model.Date).Item2; model.GameNumber = Convert.ToInt32(tdNodes[1].InnerText); model.Visitor = tdNodes[2].InnerText; model.Home = tdNodes[3].InnerText; model.RosterLink = NhlGamesRtss.ParseLinkFromTd(tdNodes[4]); model.GameLink = NhlGamesRtss.ParseLinkFromTd(tdNodes[5]); model.EventsLink = NhlGamesRtss.ParseLinkFromTd(tdNodes[6]); model.FaceOffsLink = NhlGamesRtss.ParseLinkFromTd(tdNodes[7]); model.PlayByPlayLink = NhlGamesRtss.ParseLinkFromTd(tdNodes[8]); model.ShotsLink = NhlGamesRtss.ParseLinkFromTd(tdNodes[9]); model.HomeToiLink = NhlGamesRtss.ParseLinkFromTd(tdNodes[10]); model.VistorToiLink = NhlGamesRtss.ParseLinkFromTd(tdNodes[11]); model.ShootoutLink = NhlGamesRtss.ParseLinkFromTd(tdNodes[12]); return(model); }
private static List <Nhl_Games_Rtss> UpdateSeason(int year, NhlSeasonType nhlSeasonType, DateTime fromDate, bool saveToDb) { // Get HTML rows NhlGamesRtss nhl = new NhlGamesRtss(); List <HtmlNode> rows = nhl.GetResultsForSeasonType(year, nhlSeasonType, fromDate); // Parse into a list List <Nhl_Games_Rtss> results = new List <Nhl_Games_Rtss>(); foreach (HtmlNode row in rows) { Nhl_Games_Rtss result = NhlGamesRtss.MapHtmlRowToModel(row, nhlSeasonType); if (null != result) { results.Add(result); } } // Update DB if (saveToDb) { NhlGamesRtss.AddOrUpdateDb(results); } return(results); }