public List <Match> GetNextMatchesByCompetition(string CompetitionId) { DALMatches dalMatches = new DALMatches(connectionString); List <Match> nextMatches = dalMatches.GetSpNextMatchesByCompetitionId(CompetitionId); nextMatches.ForEach(EntityBuilder); return(nextMatches); }
public List <Match> GetMatchesByCompetitionAndRangeDates(string CompetitionId, DateTime StartDate, DateTime FinalDate) { DALMatches dalMatches = new DALMatches(connectionString); List <Match> lstMatches = dalMatches.GetByCompetitionIdAndByRangeDates(CompetitionId, StartDate, FinalDate); lstMatches.ForEach(EntityBuilder); return(lstMatches); }
// MATCHES METHODS. public Match GetMatchById(string Id) { DALMatches dalMatches = new DALMatches(connectionString); Match match = dalMatches.GetById(Id); EntityBuilder(match); return(match); }
public bool UpdateMatches(List <Match> Matches) { if (Matches is null) { return(false); } DALMatches dalMatches = new DALMatches(connectionString); dalMatches.Update(Matches); return(true); }
public List <Match> GetNextMatchesByTierOneCompetitions() { DALMatches dalMatches = new DALMatches(connectionString); List <Match> nextMatches = new List <Match>(); foreach (Competition competition in TierOneCompetitions()) { nextMatches.AddRange(dalMatches.GetSpNextMatchesByCompetitionId(competition.Id.ToString())); } nextMatches.ForEach(EntityBuilder); return(nextMatches); }
public bool SyncMatchesTierOne() { DALMatches dalMatches = new DALMatches(connectionString); // Object to comunicate with Database. ResourceMatches resourceMatches = new ResourceMatches(apiToken); // Object to comunicate with API football-data.org. foreach (Competition competition in TierOneCompetitions()) // Foreach tier_one competition. { List <Match> lstInsertMatches = new List <Match>(); // Temporary list to hold insertable matches. List <Match> lstUpdateMatches = new List <Match>(); // Temporary list to hold updatable matches. List <Match> lstApiMatches = resourceMatches.GetByCompetition(competition.Id.ToString()); // Get a list of matches by competition from the Api. foreach (Match apiMatch in lstApiMatches) // Foreach match in lstApiMatches. { if (apiMatch.HomeTeam.Id == 0 || apiMatch.AwayTeam.Id == 0) // 0 == null. Do not insert or update. { continue; } Match dbMatch = dalMatches.GetById(apiMatch.Id.ToString()); // Tries to get the same match from db. if (dbMatch is null) // If no match then add match to insertable matches list. { lstInsertMatches.Add(apiMatch); } else // Otherwise { DateTime?apiLastUpdated = NormalizeApiDateTime(apiMatch.LastUpdated); // First normalize the datetime that came from the api to our standard. if (dbMatch.LastUpdated != apiLastUpdated.ToString()) // if Api Last Update is diferent from the corresponding db value. { lstUpdateMatches.Add(apiMatch); // Add match to updatable matches list. } } } if (lstInsertMatches.Count != 0) { dalMatches.Insert(lstInsertMatches); } if (lstUpdateMatches.Count != 0) { dalMatches.Update(lstUpdateMatches); } } return(true); }
public bool MatchesHasRows() { DALMatches dalMatches = new DALMatches(connectionString); return(dalMatches.HasRows()); }