コード例 #1
0
        /// <summary>
        /// Returns a list of string holding the alerts for the user
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static IList <string> UserAlertMessages(int userId)
        {
            UserAlertMessageViewCollection alerts = UserAlertMessageCache.GetUserAlerts(userId);

            if (alerts != null)
            {
                return(alerts.DisplayAlertMessages());
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        public static UserAlertMessageViewCollection GetUserAlerts(int userId)
        {
            string key = GetCacheKey(userId);

            CacheManager <string, UserAlertMessageViewCollection> cache = GetUserAlertMessageCache();

            UserAlertMessageViewCollection alerts = cache[key];

            if (alerts == null && userId != 0)
            {
                User user = User.FetchByID(userId);
                alerts = user.AlertMessages();
                cache.Insert(key, alerts, CacheHelper.CACHE_DURATION_IN_SECONDS);
            }

            return(alerts);
        }