Move a page to another container within the provider instance.

Namespace:  EPiServer.Core
Assembly:  EPiServer (in EPiServer.dll) Version: 5.2.375.236

Syntax

C#
public virtual void Move(
	PageReference pageLink,
	PageReference destinationLink
)

Parameters

pageLink
Type: EPiServer.Core..::.PageReference
The link to the page to move
destinationLink
Type: EPiServer.Core..::.PageReference
The container to which the page will be moved

Implements

IPageStore..::.Move(PageReference, PageReference)

Remarks

Move between page provider instances is to be seen as a create at destination followed by a delete of source. If move is to be supported this method needs to be overriden. A suggested implementation of move when destinationLink is WastebasketReference is to set WastebasketReference as parent and set property "PageDeleted" to true.

Examples

The following code sample is an implementation of Move() for XmlPageProvider.
CopyC#
public override void Move(PageReference pageLink, PageReference destinationLink)
{
    //Find all page languages
    var pageNodes = (from pageVersions in XmlPages.Descendants("page")
                     where pageVersions.Attribute("id").Value == pageLink.ID.ToString()
                     select pageVersions);
    if (pageNodes == null)
    {
        throw new PageNotFoundException(pageLink);
    }

    string parentId = (from parent in pageNodes.First().Attributes("parent")
                   select parent.Value).Single<string>();

    bool restored = WastebasketReference == ConstructPageReference(Int32.Parse(parentId));

    bool recursively = true;
    //Change parent information for the pages
    foreach (XElement pageNode in pageNodes)
    {
        pageNode.Attribute("parent").Value = destinationLink == EntryPoint ? "0" : destinationLink.ID.ToString();
        XElement parentPropertyNode = pageNode.Elements().Where(p => String.Equals(p.Attribute("name").Value, "PageParentLink")).SingleOrDefault<XElement>();
        if (parentPropertyNode != null)
        {
            //we don't store ProviderKey information in storage, GetProperty and InitializeData will take care of setting that at load. XElement propNode = pageNode.Elements().Where(p => String.Equals(p.Attribute("name").Value, "PageDeleted")).SingleOrDefault<XElement>();
            parentPropertyNode.SetValue(destinationLink.ID.ToString());
        }

        //mark page as deleted if moved to wastebasket
        if (destinationLink == WastebasketReference)
        {
            SetDeleteFlag(pageNode, true, recursively);
            recursively = false;
        }
        else if (restored)
        {
            //or remove deleted flag if page is restored
            SetDeleteFlag(pageNode, false, recursively);
            recursively = false;
        }
    }

    XmlPages.Save(_filePath);
}

Exceptions

ExceptionCondition
System..::.NotImplementedException Thrown if the Page Provider indicates support for Move with the Capabilities property, but does not override Move method.
System..::.NotSupportedException Thrown if the Page Provider does not support Move functionality.

See Also