private void HandleChangeLayout(ApiRequest request)
{
var templatePage = GetPageTemplate(request);
if (templatePage != null)
{
var pageToChange = /*PageChangingLayout ??*/ _pageSelection.CurrentSelection;
var book = _pageSelection.CurrentSelection.Book;
book.UpdatePageToTemplate(book.OurHtmlDom, templatePage.GetDivNodeForThisPage(), pageToChange.Id);
// The Page objects are cached in the page list and may be used if we issue another
// change layout command. We must update their lineage so the right "current layout"
// will be shown if the user changes the layout of the same page again.
var pageChanged = pageToChange as Page;
if (pageChanged != null)
pageChanged.UpdateLineage(new[] { templatePage.Id });
_pageRefreshEvent.Raise(PageRefreshEvent.SaveBehavior.JustRedisplay);
request.Succeeded();
}
}