public void AddItem(string term, string screenName, bool exclusive) { var newTerm = new GroupTerm { Term = term, Name = screenName, Exclusive = exclusive }; if (Terms != null && Terms.Length > 0) { var items = new List<GroupTerm>(Terms); if (!items.Contains(newTerm)) { items.Add(newTerm); } Terms = items.ToArray(); } else { Terms = new[] { newTerm }; } }
public void RemoveItem(string term) { var items = new List<GroupTerm>(Terms); var toRemove = new GroupTerm(); foreach (var t in items) { if (t.Term == term) { toRemove = t; } } if (items.Contains(toRemove)) { items.Remove(toRemove); } Terms = items.ToArray(); if(Terms.Length==0) { SpecialTimeLinesRepository.Remove(this); } SpecialTimeLinesRepository.Save(); }