/// <summary> /// TODO - This could/should be in his own class - NhlApiServices. ...2 methods. UpdatePastPlayer(), UpdatePlayer() /// </summary> public void UpDbSeason() { foreach (var team in Teams.Season) { var playerInfoEntities = GetNhlApiTeamPlayersInfo(team); if (playerInfoEntities == null) { LogError.Write(new Exception("Error"), "Fail while parsing deserialize NHl aPi Data, playerInfoEntities == null, for team:" + team); return; } if (!playerInfoEntities.Any()) { continue; } _pastPlayerInfoServices.Create(playerInfoEntities); _playerInfoServices.Update(playerInfoEntities); } }
/// <summary> /// Create PastPlayerInfo and update PlayerInfo. Then RUn user info routines, injury routine and team sched routine. /// </summary> /// <returns></returns> public ActionResult DailyFullUpdater() { Caching.ClearAllCaches(); var timer = Stopwatch.StartNew(); var api = new MySportsFeedApiTransactions(); var data = api.SplitDataTeamLists(); // Update PlayerInfo table team per team foreach (var playerInfoList in data) { _pastPlayerInfoServices.Create(playerInfoList); _playerInfoServices.Update(playerInfoList); } _playerInfoServices.UpdateStatus(); _playerInfoServices.UpdateAvg(); _playerInfoServices.UpdateInjuryStatus(); // Update UserIfo Table _userInfoServices.UpdateAll(); _userInfoServices.UpdateBestMonth(); _userInfoServices.UpdateBestDay(); //// best day must be call last after all other updates // Update TeamSchedule table -> who play today _teamScheduleServices.Update(); // Udpate Config Table - set last update time -> NOW _configServices.SetLastUpdate(DateTime.Now); Caching.ClearAllCaches(); // for DEBUG only //Debug.WriteLine("DailyFullUpdater time: " + timer.Elapsed); // For PROD only SendMessage("DailyFullUpdater", "Success", timer.Elapsed.ToString()); // fail will be sent by LogError HttpRuntime.UnloadAppDomain(); // hardcore clear app recycle! return(RedirectToAction("Index", "Home", new { Area = "Common" })); }