Beispiel #1
0
        public List <FacetDefinition> GetDefaultFacetDefinitions()
        {
            var brand = new FacetStringDefinition
            {
                FieldName   = "Brand",
                DisplayName = "Brand"
            };

            var color = new FacetStringListDefinition
            {
                DisplayName = "Color",
                FieldName   = "AvailableColors"
            };

            var size = new FacetStringListDefinition
            {
                DisplayName = "Size",
                FieldName   = "AvailableSizes"
            };

            var priceRanges = new FacetNumericRangeDefinition(_currentMarket)
            {
                DisplayName = "Price",
                FieldName   = "DefaultPrice",
                BackingType = typeof(double)
            };

            priceRanges.Range.Add(new SelectableNumericRange()
            {
                To = 50
            });
            priceRanges.Range.Add(new SelectableNumericRange()
            {
                From = 50, To = 100
            });
            priceRanges.Range.Add(new SelectableNumericRange()
            {
                From = 100, To = 500
            });
            priceRanges.Range.Add(new SelectableNumericRange()
            {
                From = 500, To = 1000
            });
            priceRanges.Range.Add(new SelectableNumericRange()
            {
                From = 1000
            });

            return(new List <FacetDefinition>()
            {
                priceRanges, brand, size, color
            });
        }
        public void Initialize(InitializationEngine context)
        {
            IFacetRegistry registry = ServiceLocator.Current.GetInstance<IFacetRegistry>();
            registry.FacetDefinitions.Add(new FacetStringDefinition()
            {
                Name = "Category",
                FieldName = "CategoryName"
            });
            registry.FacetDefinitions.Add(new FacetStringDefinition()
            {
                Name = "CountryFacet",
                FieldName = "Country"
            });

            registry.FacetDefinitions.Add(new FacetStringDefinition()
            {
                Name = "RegionFacet",
                FieldName = "Region"
            });

            FacetNumericRangeDefinition priceRanges = new FacetNumericRangeDefinition()
            {
                Name = "SalesPriceFilter",
                FieldName = "DefaultPriceAmount",
                BackingType = typeof(int)

            };
            priceRanges.Range.Add(new SelectableNumericRange() { To = 100 });
            priceRanges.Range.Add(new SelectableNumericRange() { From = 100, To = 200 });
            priceRanges.Range.Add(new SelectableNumericRange() { From = 200, To = 500 });
            priceRanges.Range.Add(new SelectableNumericRange() { From = 500 });
            registry.FacetDefinitions.Add(priceRanges);

            registry.FacetDefinitions.Add(new FacetStringListDefinition()
            {
                Name = "ColorFacet",
                FieldName = "Color"
            });

            registry.FacetDefinitions.Add(new FacetStringListDefinition()
            {
                Name = "SizesFacet",
                FieldName = "Sizes"
            });

            registry.FacetDefinitions.Add(new FacetStringDefinition()
            {
                Name = "VintageFacet",
                FieldName = "Vintage"
            });

            registry.FacetDefinitions.Add(new FacetStringDefinition()
            {
                Name = "ClosureFacet",
                FieldName = "Closure"
            });

            registry.FacetDefinitions.Add(new FacetStringDefinition()
            {
                Name = "BrandFacet",
                FieldName = "Brand"
            });

            registry.FacetDefinitions.Add(new FacetStringDefinition()
            {
                Name = "Connectivity",
                FieldName = "Connectivity"
            });
        }
Beispiel #3
0
        public virtual FacetDefinition GetFacetDefinition(FacetFilterConfigurationItem facetConfiguration)
        {
            switch (Enum.Parse(typeof(FacetFieldType), facetConfiguration.FieldType))
            {
            case FacetFieldType.String:
                return(new FacetStringDefinition
                {
                    FieldName = facetConfiguration.FieldName,
                    DisplayName = facetConfiguration.GetDisplayName()
                });

            case FacetFieldType.ListOfString:
                return(new FacetStringListDefinition
                {
                    FieldName = facetConfiguration.FieldName,
                    DisplayName = facetConfiguration.GetDisplayName()
                });

            case FacetFieldType.Boolean:
            case FacetFieldType.NullableBoolean:
                return(new FacetStringListDefinition
                {
                    FieldName = facetConfiguration.FieldName,
                    DisplayName = facetConfiguration.GetDisplayName(),
                });

            case FacetFieldType.Integer:
                return(new FacetNumericRangeDefinition(_currentMarket)
                {
                    FieldName = facetConfiguration.FieldName,
                    DisplayName = facetConfiguration.GetDisplayName(),
                    BackingType = typeof(int)
                });

            case FacetFieldType.Double:
                if (facetConfiguration.DisplayMode == FacetDisplayMode.Range.ToString() ||
                    facetConfiguration.DisplayMode == FacetDisplayMode.PriceRange.ToString())
                {
                    var rangeDefinition = new FacetNumericRangeDefinition(_currentMarket)
                    {
                        FieldName   = facetConfiguration.FieldName,
                        DisplayName = facetConfiguration.GetDisplayName(),
                        BackingType = typeof(double)
                    };

                    rangeDefinition.Range = facetConfiguration.GetSelectableNumericRanges();

                    return(rangeDefinition);
                }
                else if (facetConfiguration.DisplayMode == FacetDisplayMode.Rating.ToString())
                {
                    var rangeDefinition = new FacetAverageRatingDefinition(_currentMarket)
                    {
                        FieldName   = facetConfiguration.FieldName,
                        DisplayName = facetConfiguration.GetDisplayName(),
                        BackingType = typeof(double)
                    };

                    rangeDefinition.Range = facetConfiguration.GetSelectableNumericRanges();

                    return(rangeDefinition);
                }
                break;
            }

            return(new FacetStringDefinition
            {
                FieldName = facetConfiguration.FieldName,
                DisplayName = facetConfiguration.GetDisplayName(),
            });
        }