コード例 #1
0
        public void AddPriceFilterTags(SearchQuery searchQuery, QueryRequest request)
        {
            if (searchQuery.ContainsPriceFilter())
            {
                var priceListSystemIds = _priceListForUser.Value;
                var campaignSystemIds  = _campaignsForUser.Value;
                var allPrices          = new List <(int Min, int Max)>(searchQuery.PriceRanges);
                var countryId          = _requestModelAccessor.RequestModel.CountryModel.SystemId;

                var tagClause = new OptionalTagClause();
                foreach (var item in priceListSystemIds)
                {
                    var name = _requestModelAccessor.RequestModel.Cart.IncludeVAT
                        ? TagNames.GetTagNameForPriceIncludingVAT(item, countryId)
                        : TagNames.GetTagNameForPriceExludingVAT(item, countryId);

                    request.ReadTags.Add(name);
                    foreach (var priceItem in allPrices)
                    {
                        tagClause.Tags.Add(new RangeTag(name, priceItem.Min, priceItem.Max));
                    }
                }

                foreach (var item in campaignSystemIds)
                {
                    var name = FilteringConstants.GetCampaignTagName(item);
                    request.ReadTags.Add(name);
                    foreach (var priceItem in allPrices)
                    {
                        tagClause.Tags.Add(new RangeTag(name, priceItem.Min, priceItem.Max));
                    }
                }

                if (tagClause.TagsExist)
                {
                    request.FilterTags.Add(tagClause);
                }
            }
        }
コード例 #2
0
        public void AddFilterReadTags(QueryRequest request, Guid categorySystemId)
        {
            var cultureInfo         = new Guid(request.LanguageId).GetLanguage()?.CultureInfo;
            var priceListIDsForUser = _priceListForUser.Value;
            var campaigns           = _campaignsForUser.Value;
            var countryId           = _requestModelAccessor.RequestModel.CountryModel.SystemId;

            request.ReadTags.Add(TagNames.CategorySystemId);

            foreach (var item in priceListIDsForUser)
            {
                var name = _requestModelAccessor.RequestModel.Cart.IncludeVAT ? TagNames.GetTagNameForPriceIncludingVAT(item, countryId) : TagNames.GetTagNameForPriceExludingVAT(item, countryId);
                if (!request.ReadTags.Contains(name))
                {
                    request.ReadTags.Add(name);
                }
            }

            foreach (var item in campaigns)
            {
                var name = FilteringConstants.GetCampaignTagName(item);
                if (!request.ReadTags.Contains(name))
                {
                    request.ReadTags.Add(name);
                }
            }

            foreach (var item in _categoryFilterService.GetFilters(categorySystemId).Where(x => !x.StartsWith("#")))
            {
                var name = item.GetFieldDefinitionForProducts()?.GetTagName(cultureInfo);
                if (name != null && !request.ReadTags.Contains(name))
                {
                    request.ReadTags.Add(name);
                }
            }
        }