Beispiel #1
0
        public void DeleteNode(Node node)
        {
            IList menus = _siteStructureDao.GetMenusByParticipatingNode(node);

            foreach (CustomMenu menu in menus)
            {
                // HACK: due to a bug with proxies IList.Remove(object) always removes the first object in
                // the list. Also IList.IndexOf always returns 0. Therefore, we'll loop through the collection
                // and find the right index. Btw, when turning off proxies everything works fine.
                int positionFound = -1;
                for (int i = 0; i < menu.Nodes.Count; i++)
                {
                    if (((Node)menu.Nodes[i]).Id == node.Id)
                    {
                        positionFound = i;
                        break;
                    }
                }
                if (positionFound > -1)
                {
                    menu.Nodes.RemoveAt(positionFound);
                }
                _commonDao.SaveOrUpdateObject(menu);
            }
            _commonDao.DeleteObject(node);
        }