private BLM()
        {
            this.root = new Group() { Name = "~" };
            root.Name = "~";

            Seed();
        }
        public ActionResult New(int parentId)
        {
            BLM blm = BLM.Load();

            Group parent = (Group)blm.GetItemByID(parentId);
            Group newGroup = new Group() { Parent = parent };

            return View(newGroup);
        }
        public void AddGroup(int parentId, Group newGroup)
        {
            Group parent = (Group)GetItemByID(parentId);

            newGroup.ID = GenerateID();
            parent.AddItem(newGroup);

            Save();
        }
        public ActionResult New(int parentId, Group group)
        {
            BLM blm = BLM.Load();

            if (!ModelState.IsValid)
            {
                Group parent = (Group)blm.GetItemByID(parentId);
                group.Parent = parent;

                return View(group);
            }

            blm.AddGroup(parentId, group);

            return RedirectToAction("Index", new { id = parentId });
        }
        private void Seed()
        {
            Group friends = new Group() { ID = GenerateID(), Name = "Friends" };
            root.AddItem(friends);

            Person udi = new Person() { ID = GenerateID(), FirstName = "Udi", LastName = "Cohen" };
            friends.AddItem(udi);

            Group bestFriends = new Group() { ID = GenerateID(), Name = "Best Friends" };
            friends.AddItem(bestFriends);

            Group coWorkers = new Group() { ID = GenerateID(), Name = "Co Workers" };
            root.AddItem(coWorkers);

            Person shlomi = new Person() { ID = GenerateID(), FirstName = "Shlomi", LastName = "Agiv" };
            coWorkers.AddItem(shlomi);

            Group family = new Group() { ID = GenerateID(), Name = "Family" };
            root.AddItem(family);

            Person adva = new Person() { ID = GenerateID(), FirstName = "Adva", LastName = "Mor" };
            family.AddItem(adva);

            Person ori = new Person() { ID = GenerateID(), FirstName = "Ori", LastName = "Calvo" };
            root.AddItem(ori);
        }
        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;
        }