public BookItem GetItemByID(int?id) { BookItem res = FindItemByID(id); if (res == null) { throw new ArgumentException("Item with id: " + id.Value + " was not found"); } return(res); }
public BookItem FindItemByID(Group group, int id) { foreach (BookItem item in group.Items) { if (item.ID == id) { return(item); } if (item is Group) { Group subGroup = (Group)item; BookItem res = FindItemByID(subGroup, id); if (res != null) { return(res); } } } return(null); }
public void DeleteItem(BookItem item) { this.Items.Remove(item); item.Parent = null; }
public void AddItem(BookItem item) { this.Items.Add(item); item.Parent = this; }
public void DeleteItem(BookItem item) { item.Parent.DeleteItem(item); Save(); }