コード例 #1
0
        public IEnumerable GetAvailableProducts(string currentUser)
        {
            try
            {
                ObjectCache cache = MemoryCache.Default;
                if (cache.Contains(cacheKey))
                {
                    return((IEnumerable)cache.Get(cacheKey));
                }
                else
                {
                    IProduct    productBO       = new ProductBO(currentUser);
                    IEnumerable availableStocks = productBO.GetAllProducts();// this.GetDefaultStocks();

                    // Store data in the cache
                    CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();
                    cacheItemPolicy.AbsoluteExpiration = DateTime.Now.AddHours(6);
                    cache.Add(cacheKey, availableStocks, cacheItemPolicy);

                    return(availableStocks);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        public ResponseResult GetAllProducts()
        {
            var a = ProductBO.GetAllProducts();

            return(a);
        }