/// <summary>
        /// Changes the page layout.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="fromLayoutTemplate">From layout template.</param>
        /// <param name="toLayoutTemplate">To layout template.</param>
        public static void ChangePageLayout(Page page, PageLayoutTemplate fromLayoutTemplate,
                                            PageLayoutTemplate toLayoutTemplate)
        {
            if (fromLayoutTemplate == null || toLayoutTemplate == null)
            {
                return;
            }

            page.PageLayout.LayoutTemplate = toLayoutTemplate;
            if (fromLayoutTemplate.ColumnsNumber > toLayoutTemplate.ColumnsNumber)
            {
                page.Widgets.Update(
                    wd =>
                {
                    wd.OrderNumber =
                        wd.ColumnNumber > toLayoutTemplate.ColumnsNumber
                                 ? page.Widgets.Where(w => w.ColumnNumber == toLayoutTemplate.ColumnsNumber).Count
                            () + 1
                                 : wd.OrderNumber;
                    wd.ColumnNumber =
                        wd.ColumnNumber > toLayoutTemplate.ColumnsNumber
                                 ? toLayoutTemplate.ColumnsNumber
                                 : wd.ColumnNumber;
                }
                    );
            }

            var pageService = ServiceLocator.Current.GetInstance <IPageService>();

            pageService.Save(page);
        }
 private DevExpress.XtraBars.Ribbon.GalleryItem CreatePageLayout(PageLayoutTemplate info)
 {
     return(new DevExpress.XtraBars.Ribbon.GalleryItem()
     {
         Caption = info.Name, Description = info.Description, Value = info
     });
 }
        public virtual ActionResult ChangeLayout(long pageId, long layoutTemplateId)
        {
            var page = pageService.Find(pageId);

            if (page == null || !permissionService.IsAllowed((Int32)PageOperations.Update, this.CorePrincipal(), typeof(Page), pageId, IsPageOwner(page), PermissionOperationLevel.Object))
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.NotFound"));
            }

            var pageLayoutTemplateService =
                ServiceLocator.Current.GetInstance <IPageLayoutTemplateService>();
            PageLayoutTemplate layoutTemplate = pageLayoutTemplateService.Find(layoutTemplateId);

            if (layoutTemplate == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.NotFound"));
            }
            LayoutHelper.ChangePageLayout(page, page.PageLayout.LayoutTemplate, layoutTemplate);

            return(PartialView(MVC.Shared.Views.Layouts.Layout, PageHelper.BindPageViewModel(page, this.CorePrincipal())));
        }