private static List <Nhl_Games_Summary> UpdateSeason(int year, NhlSeasonType nhlSeasonType, DateTime fromDate, bool saveToDb) { // Get HTML rows NhlGamesSummary nhl = new NhlGamesSummary(); List <HtmlNode> rows = nhl.GetResultsForSeasonType(year, nhlSeasonType, fromDate); // Parse into a list List <Nhl_Games_Summary> results = new List <Nhl_Games_Summary>(); foreach (HtmlNode row in rows) { Nhl_Games_Summary result = NhlGamesSummary.MapHtmlRowToModel(row, nhlSeasonType); if (null != result) { results.Add(result); } } // Update DB if (saveToDb) { NhlGamesSummary.AddOrUpdateDb(results); } return(results); }
/// <summary> /// Get all the results starting from the last date of the data in the db. If a year is specified then only get latest for that year. /// </summary> /// <param name="year"></param> public static List <Nhl_Games_Summary> GetNewResultsOnly([Optional] int year, [Optional] bool saveToDb) { DateTime latestResultDate; using (SportsDataContext db = new SportsDataContext()) { latestResultDate = (from m in db.Nhl_Games_Summary_DbSet orderby m.Date descending select m.Date).FirstOrDefault(); } return(NhlGamesSummary.GetFullSeason(year, latestResultDate, saveToDb)); }
public static List <Nhl_Games_Summary> GetFullSeason([Optional] int year, [Optional] DateTime fromDate, [Optional] bool saveToDb) { List <Nhl_Games_Summary> results = new List <Nhl_Games_Summary>(); foreach (NhlSeasonType seasonType in Enum.GetValues(typeof(NhlSeasonType))) { if (seasonType == NhlSeasonType.None) { continue; } List <Nhl_Games_Summary> partialResults = NhlGamesSummary.UpdateSeason(year, seasonType, fromDate, saveToDb); if (null != partialResults) { results.AddRange(partialResults); } } return(results); }
private static List<Nhl_Games_Summary> UpdateSeason(int year, NhlSeasonType nhlSeasonType, DateTime fromDate, bool saveToDb) { // Get HTML rows NhlGamesSummary nhl = new NhlGamesSummary(); List<HtmlNode> rows = nhl.GetResultsForSeasonType(year, nhlSeasonType, fromDate); // Parse into a list List<Nhl_Games_Summary> results = new List<Nhl_Games_Summary>(); foreach (HtmlNode row in rows) { Nhl_Games_Summary result = NhlGamesSummary.MapHtmlRowToModel(row, nhlSeasonType); if (null != result) { results.Add(result); } } // Update DB if (saveToDb) { NhlGamesSummary.AddOrUpdateDb(results); } return results; }