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(),
                });
            }

            return(new FacetStringDefinition
            {
                FieldName = facetConfiguration.FieldName,
                DisplayName = facetConfiguration.GetDisplayName(),
            });
        }
Ejemplo n.º 2
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(),
            });
        }