public bool SyncTeams() { ResourceTeams resourceTeams = new ResourceTeams(apiToken); // Object to comunicate with API football-data.org. DALTeams dalTeams = new DALTeams(connectionString); // Object to comunicate with Database. List <Team> lstInsertTeams = new List <Team>(); // Temporary List<Competition> to insert. List <Team> lstUpdateTeams = new List <Team>(); // Temporary List<Competition> to update. foreach (Competition competition in TierOneCompetitions()) // Foreach tier_one competition. { List <Team> lstTeams = resourceTeams.GetByCompetition(competition.Id.ToString()); // Get all the teams from the API. foreach (Team apiTeam in lstTeams) // Foreach apiTeam. { Team dbTeam = dalTeams.GetById(apiTeam.Id.ToString()); // Get Team by Id from db. if (dbTeam == null) // If dbTeam null then add to lstInsertTeams. { if (lstInsertTeams.Find(x => x.Id == apiTeam.Id) is null) // But first find out if lstInsertTeams has already dbTeam. { lstInsertTeams.Add(apiTeam); // If not add to lstInsertTeams. } continue; } if (apiTeam.LastUpdated == null) // If apiTeam.LastUpdated == null no need to update. { continue; } DateTime?apiTeamLastUpdated = NormalizeApiDateTime(apiTeam.LastUpdated); if (apiTeamLastUpdated.ToString() != dbTeam.LastUpdated) { lstUpdateTeams.Add(apiTeam); } } } if (lstInsertTeams.Count != 0) { dalTeams.Insert(lstInsertTeams); } if (lstUpdateTeams.Count != 0) { dalTeams.Update(lstUpdateTeams); } return(true); }
void Start() { cooldown = secondsPerGive; team = GetComponent <Team>(); resourceTeam = GameObject.FindObjectOfType <ResourceTeams>(); }
void Start() { team = GetComponentInParent <Team>(); //cameraCommander = GetComponentInParent<Camera>(); ResourceTeam = GameObject.FindObjectOfType <ResourceTeams>(); }
void Start() { BuildingPlacement = GetComponentInChildren <BuildingPlacement>(); Tooltip = GetComponentInChildren <Tooltip>(); ResourceManager = GameObject.FindObjectOfType <ResourceTeams>(); }