/* * private void CreateDisplayFilters(FilteredBrowsing browsing) * { * List<RangeFilter> filters = null; * * if (browsing.AttributeRanges != null) * { * filters = new List<RangeFilter>(browsing.AttributeRanges); * } * else * { * filters = new List<RangeFilter>(); * } * * var filter = new RangeFilter(); * filter.Key = "DisplaySize"; * * var vals = new List<RangeFilterValue>(); * * vals.Add(CreateRange("20 Inches & Under", "under-i20", String.Empty, "20", "en")); * vals.Add(CreateRange("21 to 29 Inches", "i21-29", "21", "29", "en")); * vals.Add(CreateRange("30 to 39 Inches", "i21-29", "30", "39", "en")); * vals.Add(CreateRange("40 to 49 Inches", "i21-29", "40", "49", "en")); * vals.Add(CreateRange("50 Inches & Up", "over-i50", "50", String.Empty, "en")); * * filters.Add(filter); * * browsing.AttributeRanges = filters.ToArray(); * } */ private static void CreateFilters(FilteredBrowsing browsing) { var filters = browsing.Attributes != null ? new List <AttributeFilter>(browsing.Attributes) : new List <AttributeFilter>(); var vals = new List <AttributeFilterValue>(); var filter = new AttributeFilter { Key = "Brand" }; var val = new AttributeFilterValue { Id = "samsung", Value = "samsung" }; var val2 = new AttributeFilterValue { Id = "sony", Value = "sony" }; var val3 = new AttributeFilterValue { Id = "apple", Value = "apple" }; vals.Add(val); vals.Add(val2); vals.Add(val3); filter.Values = vals.ToArray(); filters.Add(filter); browsing.Attributes = filters.ToArray(); }
protected virtual FilteredBrowsing GetFilteredBrowsing(Store store) { FilteredBrowsing result = null; var filterSettingValue = store.GetDynamicPropertyValue("FilteredBrowsing", string.Empty); if (!string.IsNullOrEmpty(filterSettingValue)) { var reader = new StringReader(filterSettingValue); result = _serializer.Deserialize(reader) as FilteredBrowsing; } return(result); }
private static FilteredBrowsing GetFilteredBrowsing(Store store) { FilteredBrowsing result = null; var filterSettingValue = store.GetDynamicPropertyValue(_filteredBrowsingPropertyName, string.Empty); if (!string.IsNullOrEmpty(filterSettingValue)) { var reader = new StringReader(filterSettingValue); var serializer = new XmlSerializer(typeof(FilteredBrowsing)); result = serializer.Deserialize(reader) as FilteredBrowsing; } return(result); }
private static string CreateFiltersXml() { var browsing = new FilteredBrowsing(); CreateFilters(browsing); CreateColorFilters(browsing); CreatePriceFilters(browsing); var serializer = new XmlSerializer(typeof(FilteredBrowsing)); var writer = new StringWriter(); serializer.Serialize(writer, browsing); var filtersXml = writer.ToString(); return(filtersXml); }
private static void CreateColorFilters(FilteredBrowsing browsing) { var filters = browsing.Attributes != null ? new List <AttributeFilter>(browsing.Attributes) : new List <AttributeFilter>(); var filter = new AttributeFilter { Key = "color", IsLocalized = false }; var colors = new[] { "White", "Black", "Red", "Yellow", "Green", "Blue", "Pink", "Magenta" }; //var index = 0; filter.Values = colors.Select(color => new AttributeFilterValue { Id = color.ToLower(), Value = color.ToLower() }).ToArray(); filters.Add(filter); browsing.Attributes = filters.ToArray(); }
private static void CreatePriceFilters(FilteredBrowsing browsing) { var filters = browsing.Prices != null ? new List <PriceRangeFilter>(browsing.Prices) : new List <PriceRangeFilter>(); var vals = new List <RangeFilterValue>(); var filter = new PriceRangeFilter { Currency = "USD", IsLocalized = false }; vals.Add(CreateRange("Under $100", "under-100", String.Empty, "100", "en")); vals.Add(CreateRange("$100 - $200", "100-200", "100", "200", "en")); vals.Add(CreateRange("$200 - $600", "200-600", "200", "600", "en")); vals.Add(CreateRange("$600 - $1000", "600-1000", "600", "1000", "en")); vals.Add(CreateRange("Over $1000", "over-1000", "1000", String.Empty, "en")); filter.Values = vals.ToArray(); filters.Add(filter); vals = new List <RangeFilterValue>(); filter = new PriceRangeFilter { Currency = "EUR", IsLocalized = false }; vals.Add(CreateRange("Under 100€", "under-100", String.Empty, "100", "en")); vals.Add(CreateRange("100€ - 200€", "100-200", "100", "200", "en")); vals.Add(CreateRange("200€ - 600€", "200-600", "200", "600", "en")); vals.Add(CreateRange("600€ - 1000€", "600-1000", "600", "1000", "en")); vals.Add(CreateRange("Over 1000€", "over-1000", "1000", String.Empty, "en")); filter.Values = vals.ToArray(); filters.Add(filter); browsing.Prices = filters.ToArray(); }