public void RemoveAll(CatConditionType catType) { switch (catType) { case CatConditionType.Ignore: _ignore.RemoveAll(x => true); break; case CatConditionType.CrossSell: _crossSellCats.RemoveAll(x => true); break; case CatConditionType.Exclude: _excludeCats.RemoveAll(x => true); break; case CatConditionType.Filter: _filterCats.RemoveAll(x => true); break; case CatConditionType.Universal: _universalCats.RemoveAll(x => true); break; } }
public bool RemoveCat(CatConditionType catType, string value, string groupId = null) { if (string.IsNullOrEmpty(value)) return false; var found = false; switch (catType) { case CatConditionType.Ignore: found = _ignore.Remove(value); break; case CatConditionType.CrossSell: found = _crossSellCats.Remove(value); break; case CatConditionType.Exclude: found = _excludeCats.Remove(value); break; case CatConditionType.Filter: found = _filterCats.Remove(new FilterCatDef(value, string.IsNullOrEmpty(groupId) ? value : groupId)); break; case CatConditionType.Universal: found = _universalCats.Remove(string.IsNullOrEmpty(groupId) ? value : groupId); break; } return found; }
public bool AddCat(CatConditionType catType, string value, string groupId = null) { if (string.IsNullOrEmpty(value)) return false; switch (catType) { case CatConditionType.Ignore: if (_ignore.Contains(value)) return false; _ignore.Add(value); return true; case CatConditionType.CrossSell: if (_crossSellCats.Contains(value)) return false; _crossSellCats.Add(value); return true; case CatConditionType.Exclude: if (_excludeCats.Contains(value)) return false; _excludeCats.Add(value); return true; case CatConditionType.Filter: var group = string.IsNullOrEmpty(groupId) ? value : groupId; if (_filterCats.Any(x => x.CatId.Equals(value) && x.GroupId.Equals(group))) return false; _filterCats.Add(new FilterCatDef(value, group)); return true; case CatConditionType.Universal: if (_universalCats.Contains(value)) return false; _universalCats.Add(value); return true; } return false; }