예제 #1
0
        public async Task <ICollection <Product> > GetProductsAsync(int categoryId)
        {
            string cacheFileName = string.Format("SubProductsOfCategoryId{0}", categoryId);

            try
            {
                // Retrieve the items from the cache
                return(await _cacheService.GetDataAsync <ICollection <Product> >(cacheFileName));
            }
            catch (FileNotFoundException)
            {
            }

            // Retrieve the items from the service
            var products = await _productCatalogService.GetProductsAsync(categoryId);

            await _cacheService.SaveDataAsync(cacheFileName, products);

            return(products);
        }
예제 #2
0
 public async Task <IEnumerable <Product> > GetProductsAsync()
 {
     return(await _productCatalogService.GetProductsAsync());
 }