Beispiel #1
0
        public async Task <Category> GetCategoryAsync(int categoryId)
        {
            string cacheFileName = string.Format("CategoryId{0}", categoryId);

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

            // Retrieve the items from the service
            var category = await _productCatalogService.GetCategoryAsync(categoryId);

            // Save the items in the cache
            await _cacheService.SaveDataAsync(cacheFileName, category);

            return(category);
        }