private List <FilterGroup> GetProductFilterGroups(TreeNode productCategoryDocument, string targetOptionsFieldName) { var productFilterGroups = new List <FilterGroup>(); if (productCategoryDocument != null) { var delimitedOptions = ValidationHelper.GetString(productCategoryDocument[targetOptionsFieldName], string.Empty); if (string.IsNullOrEmpty(delimitedOptions)) { return(productFilterGroups); } var options = delimitedOptions.Trim().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToList(); foreach (var option in options) { if (option.Trim().ToUpper() == "MISCELLANEOUSATTRIBUTES" || option.Trim().ToUpper() == "VERTICALS" || option.Trim().ToUpper() == "PEXPRODUCTATTRIBUTES") { string option1 = option; var filterOptions = AllProductFields.Where(x => x.Category == option1.Trim()); foreach (var filterOption in filterOptions) { if (productFilterGroups.All(x => x.FieldName != filterOption.FieldName)) { var newFilterOption = new FilterGroup { DisplayName = filterOption.DisplayName, FieldName = filterOption.FieldName, Category = option.Trim(), IsCategoryGroup = true, FieldType = filterOption.FieldType }; newFilterOption.IsCategory = !string.IsNullOrEmpty(newFilterOption.Category) && newFilterOption.FieldName == newFilterOption.Category; productFilterGroups.Add(newFilterOption); } } continue; } var field = AllProductFields.FirstOrDefault(x => x.FieldName.ToUpper() == option.Trim().ToUpper()); if (field != null && productFilterGroups.All(x => x.FieldName != field.FieldName)) { var filterGroup = new FilterGroup { DisplayName = field.DisplayName, FieldName = field.FieldName, FieldType = field.FieldType }; productFilterGroups.Add(filterGroup); } } } return(productFilterGroups); }
private List <FilterField> GetFields(TreeNode productFamilyDocument, string targetOptionsFieldName) { var fields = new List <FilterField>(); var delimitedOptions = ValidationHelper.GetString(productFamilyDocument[targetOptionsFieldName], string.Empty); if (string.IsNullOrEmpty(delimitedOptions)) { return(fields); } var options = delimitedOptions.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList(); foreach (var option in options) { var field = AllProductFields.FirstOrDefault(x => String.Equals(x.FieldName, option.Trim(), StringComparison.CurrentCultureIgnoreCase)); if (field != null) { fields.Add(field); } } return(fields); }