/// <summary> /// Get the current campaignType of a campaignType. The cache is not bypassed by default. /// </summary> /// <param name="channelTypeId">The campaignType identifier</param> /// <param name="noCache">Bypass the cache</param> /// <param name="refreshCache">Force refresh the cache</param> /// <returns>A campaignType</returns> public ChannelType GetChannelType(int channelTypeId, bool noCache, bool refreshCache) { // If no cache the load and return a entity from the database if (noCache && !refreshCache) { return(LoadChannelType(channelTypeId)); } ChannelType campaignType; string cacheKey = ChannelType.GetCacheKeyById(channelTypeId); if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ChannelType>(cacheKey) || refreshCache) { // Load the entity from the database campaignType = LoadChannelType(channelTypeId); if (campaignType != null) { // Add the entity to the cache by reading caching parameters from the configuration CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, campaignType, ConfigurationManager.GetCacheExpirationByType( campaignType.GetType())); } } else { campaignType = CacheManagerProvider.GetCacheManagerInstance().Get <ChannelType>(cacheKey); } return(campaignType); }