/// <summary>
	    /// Converts the specified filter to filter model.
	    /// </summary>
	    /// <param name="helper"></param>
	    /// <param name="filter">The search filter.</param>
	    /// <returns>Filter model</returns>
	    public static FilterModel Convert(this SearchHelper helper, ISearchFilter filter)
		{
			var model = new FilterModel();

			if (filter is AttributeFilter)
			{
				var prop = filter as AttributeFilter;
				model.Key = prop.Key;
				model.Name = helper.CatalogClient.GetPropertyName(prop.Key);
				model.Name = string.IsNullOrEmpty(model.Name) ? model.Key : model.Name;
				return model;
			}
			if (filter is RangeFilter)
			{
				var prop = filter as RangeFilter;
				model.Key = prop.Key;
				model.Name = helper.CatalogClient.GetPropertyName(prop.Key);
				model.Name = string.IsNullOrEmpty(model.Name) ? model.Key : model.Name;
				return model;
			}
			if (filter is PriceRangeFilter)
			{
				var prop = filter as PriceRangeFilter;
				model.Key = prop.Key;
				model.Name = "Price";
				return model;
			}

			return null;
		}
        /// <summary>
        /// Converts the specified filter to filter model.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="filter">The search filter.</param>
        /// <returns>Filter model</returns>
        public static FilterModel Convert(this ISearchFilterService helper, ISearchFilter filter)
        {
            var model = new FilterModel();

            if (filter is AttributeFilter)
            {
                var prop = filter as AttributeFilter;
                model.Key = prop.Key;
                model.Name = ClientContext.Clients.CreateCatalogClient().GetPropertyName(prop.Key);
                model.Name = string.IsNullOrEmpty(model.Name) ? model.Key : model.Name;
                return model;
            }
            if (filter is RangeFilter)
            {
                var prop = filter as RangeFilter;
                model.Key = prop.Key;
                model.Name = ClientContext.Clients.CreateCatalogClient().GetPropertyName(prop.Key);
                model.Name = string.IsNullOrEmpty(model.Name) ? model.Key : model.Name;
                return model;
            }
            if (filter is PriceRangeFilter)
            {
                var prop = filter as PriceRangeFilter;
                model.Key = prop.Key;
                model.Name = "Price";
                return model;
            }
            if (filter is CategoryFilter)
            {
                var prop = filter as CategoryFilter;
                model.Key = prop.Key;
                model.Name = "Category";
                return model;
            }

            return null;
        }
Example #3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="SelectedFilterModel"/> class.
		/// </summary>
		/// <param name="filter">The filter.</param>
		/// <param name="facet">The facet.</param>
        public SelectedFilterModel(FilterModel filter, FacetModel facet)
        {
            Filter = filter;
            Facet = facet;
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectedFilterModel"/> class.
 /// </summary>
 /// <param name="filter">The filter.</param>
 /// <param name="facet">The facet.</param>
 public SelectedFilterModel(FilterModel filter, FacetModel facet)
 {
     Filter = filter;
     Facet  = facet;
 }