예제 #1
0
        private static bool IsUserAuthorizedOn(string user, int universeId, Entities context)
        {
            bool isAuthorized;
            var  key = string.Format("user:{0}-universe:{1}", user, universeId);

            if (!UserUniversesRights.TryGetValue(key, out isAuthorized))
            {
                isAuthorized             = context.UniverseAvailables.Any(x => x.UserName == user && x.IdUniverse == universeId);
                UserUniversesRights[key] = isAuthorized;
            }
            return(isAuthorized);
        }
예제 #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;
            }
        }