Beispiel #1
0
        public void Move(PageItem from, PageItem to, DropPosition dropPosition)
        {
            var pageCache = PageCache.From(_session);

            if (dropPosition == DropPosition.Over)
            {
                to.Pages.Add(from);
                to.Pages.AdjustOrders(false);
                return;
            }

            if (dropPosition == DropPosition.Before)
            {
                var pages = new PageItemCollectionWrapper(to.Parent == null ? pageCache.RootPages : to.Parent.Pages);

                if (from.IsSiblingOf(to))
                {
                    pages.MoveBefore(to, from);
                }
                else
                {
                    pages.AddBefore(to, from);
                }

                pages.AdjustOrders(false);

                return;
            }

            if (dropPosition == DropPosition.After)
            {
                var pages = new PageItemCollectionWrapper(to.Parent == null ? pageCache.RootPages : to.Parent.Pages);

                if (from.IsSiblingOf(to))
                {
                    pages.MoveAfter(to, from);
                }
                else
                {
                    pages.AddAfter(to, from);
                }

                pages.AdjustOrders(false);
            }
        }