public bool AddFilter(string groupId, string comparison, string value, string field) { //special case for category rules if (field.Equals("Category_4T")) { if (string.IsNullOrEmpty(value)) return false; if (CategoryRules == null) CategoryRules = new CategoryConditions(); else { //new list replaces all old ones if (CategoryRules.FiltersExist) CategoryRules.Filters.RemoveAll(x => x.GroupId.Equals(groupId)); } foreach (var id in value.Split(new[] { ',' })) CategoryRules.AddCat(CategoryConditions.CatConditionType.Filter, id, groupId); } else { //for normal filters, make sure they are unique if (FilterRules == null) FilterRules = new List<Condition>(); else { if (FilterRules.Any(x => x.Equals(groupId, comparison, value, field))) throw new Exception(string.Format("Unable to add Filter {0} for {1}: equivalent rule already exists", groupId, Alias)); } var rule = new Condition(groupId, comparison, value, field); FilterRules.Add(rule); } QueueSettings(); return true; }
public bool AddExclusion(string name, string comparison, string value, string field) { //special case for category rules if (field.Equals("Category_4T")) { if (string.IsNullOrEmpty(value)) return false; if (CategoryRules == null) CategoryRules = new CategoryConditions(); else { //new list replaces all old ones if (CategoryRules.ExclusionsExist) CategoryRules.RemoveAll(CategoryConditions.CatConditionType.Exclude); } foreach (var id in value.Split(new[] { ',' })) CategoryRules.AddCat(CategoryConditions.CatConditionType.Exclude, id); } else { if (ExclusionRules == null) ExclusionRules = new List<Condition>(); else { //ignore name for exclusion equality if (ExclusionRules.Any(x => x.Equals("", comparison, value, field))) throw new Exception(string.Format("Unable to add Exclusion {0} for {1}: equivalent rule already exists", string.IsNullOrEmpty(name) ? field : name, Alias)); } var rule = new Condition(name, comparison, value, field); ExclusionRules.Add(rule); } QueueSettings(); return true; }
public bool AddCatOptimization(string value) { if (CategoryRules == null) CategoryRules = new CategoryConditions(); if (!CategoryRules.AddCat(CategoryConditions.CatConditionType.Ignore, value)) return false; QueueSettings(); return true; }
public bool AddCrossAtt1(string value) { if (CategoryRules == null) CategoryRules = new CategoryConditions(); if (!CategoryRules.AddCat(CategoryConditions.CatConditionType.CrossSell, value)) return false; QueueSettings(); return true; }
private void InitializeStructures() { CategoryRules = new CategoryConditions(); Fields = new DataFieldList(Alias); if (_cartRules == null) _cartRules = new Dictionary<CartType, XElement>(); }