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