Bloom.Book.Book.RelocatePage C# (CSharp) Method

RelocatePage() public method

Move a page to somewhere else in the book
public RelocatePage ( IPage page, int indexOfItemAfterRelocation ) : bool
page IPage
indexOfItemAfterRelocation int
return bool
        public bool RelocatePage(IPage page, int indexOfItemAfterRelocation)
        {
            Guard.Against(Type != BookType.Publication, "Tried to edit a non-editable book.");

            if(!CanRelocatePageAsRequested(indexOfItemAfterRelocation))
            {

                return false;
            }

            ClearPagesCache();

            var pages = GetPageElements();
            var pageDiv = FindPageDiv(page);
            var body = pageDiv.ParentNode;
                body.RemoveChild(pageDiv);
            if(indexOfItemAfterRelocation == 0)
            {
                body.InsertBefore(pageDiv, body.FirstChild);
            }
            else
            {
                body.InsertAfter(pageDiv, pages[indexOfItemAfterRelocation-1]);
            }
            BuildPageCache();
            Save();
            InvokeContentsChanged(null);
            return true;
        }
Book