Beispiel #1
0
        private string GetGoodsFilterCacheKey(GoodsFilter filter, bool activeActionsOnly)
        {
            string cacheKey =
                $"GOODS:{String.Join(",", filter.Articles)}:{String.Join(",", filter.CategoryIds)}:{String.Join(",", filter.Countries)}:{String.Join(",", filter.ManufacturerIds)}:{String.Join(",", filter.Packs)}:{filter.SearchPattern}:{filter.SortBy}:{filter.ClientMode}";

            return(cacheKey);
        }
Beispiel #2
0
        /// <summary>
        /// Получить список товаров, удовлетворяющий фильтру
        /// </summary>
        /// <param name="filter">Сам фильтр</param>
        /// <param name="startIndex">Индекс первого элемента в выборке (начинается с 1, 1-based)</param>
        /// <param name="count">Количество элементов</param>
        /// <param name="totalCount">Всего элементов, выходной параметр</param>
        /// <param name="collections">Данные, которые представлены в товарах этой выборки</param>
        /// <param name="activeActionsOnly">В товар достаются только активные акции, а не все, в которых он участвовал</param>
        /// <returns></returns>
        public IList <GoodsItem> GetGoodsSet(GoodsFilter filter, int startIndex, int count, out int totalCount, out FilterCollections collections,
                                             bool activeActionsOnly = true)
        {
            var dataFilter = Mapper.Map <Data.Models.GoodsFilter>(filter);
            var heartIds   = _goodsItemGateway.FilterGoods(dataFilter, 1, int.MaxValue, out int totalGoodsFilter);

            if (heartIds == null || !heartIds.Any())
            {
                totalCount  = 0;
                collections = new FilterCollections();
                return(new List <GoodsItem>());
            }
            collections = new FilterCollections
            {
                Manufacturers = _goodsItemGateway.GetManufacturers(heartIds),
                Countries     = _goodsItemGateway.GetCountries(heartIds),
                Packs         = _goodsItemGateway.GetPacks(heartIds)
            };
            var specValues = _goodsItemGateway.GetSpecs(heartIds);

            foreach (var spec in specValues)
            {
                var colSpec = collections.SpecValues.Keys.SingleOrDefault(x => x.SpecId == spec.Key);
                if (colSpec == null)
                {
                    var filterSpec = _shopSpecService.GetSpec(spec.Key);
                    if (filterSpec == null)
                    {
                        continue;
                    }
                    collections.SpecValues.Add(filterSpec, new List <string>()
                    {
                        spec.Value
                    });
                }
                else
                {
                    collections.SpecValues[colSpec].Add(spec.Value);
                }
            }
            totalCount = heartIds.Count;
            var goodsPage = heartIds.Skip(startIndex - 1).Take(count);
            var result    = new List <GoodsItem>();

            foreach (int heartId in goodsPage)
            {
                result.Add(GetGoods(heartId, activeActionsOnly));
            }
            return(result);
            //TODO: кэш
        }
Beispiel #3
0
        private string GetGoodsPageFilterCacheKey(GoodsFilter filter, int startIndex, int count, bool activeActionsOnly)
        {
            string cacheKey = $"GOODSPAGE:{GetGoodsFilterCacheKey(filter, activeActionsOnly)}:{startIndex}:{count}";

            return(cacheKey);
        }