Пример #1
0
        /// <summary>
        /// Get catalog items
        /// </summary>
        /// <param name="catalogPageFiltersViewModel"></param>
        /// <param name="useCache"></param>
        /// <param name="convertPrice"></param>
        /// <param name="cancelattionToken"></param>
        /// <returns></returns>
        public async Task <CatalogIndexViewModel> GetCatalogItems(CatalogPageFiltersViewModel catalogPageFiltersViewModel, bool useCache, bool convertPrice = false, CancellationToken cancelattionToken = default(CancellationToken))
        {
            if (useCache)
            {
                var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(catalogPageFiltersViewModel);

                return(await _cache.GetOrCreateAsync(cacheKey, async entry =>
                {
                    entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
                    return await _catalogViewModelService.GetCatalogItems(catalogPageFiltersViewModel, useCache, convertPrice, cancelattionToken);
                }));
            }
            else
            {
                return(await _catalogViewModelService.GetCatalogItems(catalogPageFiltersViewModel, useCache, convertPrice, cancelattionToken));
            }
        }
Пример #2
0
        public async Task <CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int?brandId, int?typeId, int?materialId)
        {
            var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(pageIndex, Constants.ITEMS_PER_PAGE, brandId, typeId, materialId);

            return(await _cache.GetOrCreateAsync(cacheKey, async entry =>
            {
                entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
                return await _catalogViewModelService.GetCatalogItems(pageIndex, itemsPage, brandId, typeId, materialId);
            }));
        }
        public async Task <CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int?brandId, int?typeId)
        {
            string cacheKey = String.Format(_itemsKeyTemplate, pageIndex, itemsPage, brandId, typeId);

            return(await _cache.GetOrCreateAsync(cacheKey, async entry =>
            {
                entry.SlidingExpiration = _defaultCacheDuration;
                return await _catalogViewModelService.GetCatalogItems(pageIndex, itemsPage, brandId, typeId);
            }));
        }
        public async Task <CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, string searchText, int?brandId, int?typeId, bool convertPrice = true, CancellationToken cancellationToken = default(CancellationToken))
        {
            var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(pageIndex, Constants.ITEMS_PER_PAGE, searchText, brandId, typeId, CultureInfo.CurrentCulture.Name);

            return(await _cache.GetOrCreateAsync(cacheKey, async entry =>
            {
                entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
                return await _catalogViewModelService.GetCatalogItems(pageIndex, itemsPage, searchText, brandId, typeId, convertPrice, cancellationToken);
            }));
        }