/// <summary> /// Get the product item. The cache is not bypassed by default. /// </summary> /// <param name="productId">The product identifier</param> /// <param name="noCache">Bypass the cache</param> /// <param name="refreshCache">Force refresh the cache</param> /// <returns>A product</returns> public ProductItem GetProductItem(string itemCode, bool noCache, bool refreshCache) { // If no cache the load and return a entity from the database if (noCache && !refreshCache) { return(GetProductByItemCode(itemCode)); } ProductItem product; string cacheKey = ProductItem.GetCustomCacheKey(itemCode); if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ProductItem>(cacheKey) || refreshCache) { // Load the entity from the database product = GetProductByItemCode(itemCode); if (product != null) { // Add the entity to the cache by reading caching parameters from the configuration CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, product, ConfigurationManager.GetCacheExpirationByType( product.GetType())); } } else { product = CacheManagerProvider.GetCacheManagerInstance().Get <ProductItem>(cacheKey); } return(product); }