Пример #1
0
        /// <summary>
        ///     Get the current channelOwner of a channelOwner. The cache is not bypassed by default.
        /// </summary>
        /// <param name="channelOwnerId">The channelOwner identifier</param>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A channelOwner</returns>
        public ChannelOwner GetChannelOwner(int channelOwnerId, bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity from the database
            if (noCache && !refreshCache)
            {
                return(LoadChannelOwner(channelOwnerId));
            }

            ChannelOwner channelOwner;

            string cacheKey = ChannelOwner.GetCacheKeyById(channelOwnerId);

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ChannelOwner>(cacheKey) || refreshCache)
            {
                // Load the entity from the database
                channelOwner = LoadChannelOwner(channelOwnerId);

                if (channelOwner != null)
                {
                    // Add the entity to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, channelOwner,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              channelOwner.GetType()));
                }
            }
            else
            {
                channelOwner = CacheManagerProvider.GetCacheManagerInstance().Get <ChannelOwner>(cacheKey);
            }

            return(channelOwner);
        }