public static bool TryGetUniverseCompetitionId(int universeId, int competitionId, Entities context, out int id) { var key = string.Format("{0}-{1}", universeId, competitionId); if (!UniverseCompetitions.TryGetValue(key, out id)) { var universeCompetition = context.UniverseCompetitions.FirstOrDefault( x => x.IdCompetition == competitionId && x.IdUniverse == universeId); if (universeCompetition == null) { return(false); } UniverseCompetitions[key] = universeCompetition.Id; id = universeCompetition.Id; } return(true); }
public static void ClearCache(Caches cache) { switch (cache) { case Caches.All: CompetitionTeams.Clear(); Teams.Clear(); TeamsValue.Clear(); UniverseCompetitions.Clear(); UserCompetitions.Clear(); UserUniversesRights.Clear(); CompetitionTeams.Clear(); Pricer.PricerHelper.Clear(); UserUniversesRights.Clear(); return; case Caches.TeamsName: Teams.Clear(); return; case Caches.TeamsValue: TeamsValue.Clear(); return; case Caches.UniverseCompetitions: UniverseCompetitions.Clear(); return; case Caches.UserCompetitions: UserCompetitions.Clear(); return; case Caches.UserUniversesRights: UserUniversesRights.Clear(); return; case Caches.UserDefaultUniverse: UserDefaultUniverse.Clear(); return; } }