public static bool TryGetTeamIdForCompetition(int competitionId, string teamName, out Team team)
        {
            var key = teamName + "-" + competitionId;

            if (!TeamsValue.TryGetValue(key, out team))
            {
                using (var context = new Entities())
                {
                    team = context.Teams.FirstOrDefault(x => x.IdCompetition == competitionId && x.Name == teamName);
                    if (team == null)
                    {
                        return(false);
                    }
                    TeamsValue[key] = team;
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        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;
            }
        }