Example #1
0
        public async Task <ActionResult> PageEdit_Partial(EditModel model)
        {
            PageDefinition page = await PageDefinition.LoadAsync(model.PageGuid);

            if (page == null)
            {
                throw new Error(this.__ResStr("alreadyDeleted", "This page has been removed and can no longer be updated."));
            }

            model.UpdateData(page);
            ObjectSupport.CopyData(page, model.Page, ReadOnly: true); // update read only properties in model in case there is an error
            model.Page.FavIcon_Data = page.FavIcon_Data;              // copy favicon
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }
            page = model.GetData(page);  // merge new data into original
            model.SetData(page);         // and all the data back into model for final display

            await page.SaveAsync();      // this handles changing the Url automatically

            MenuList.ClearCachedMenus(); // page changes may affect all menus so clear the menu cache (this only clears current session)
            // if we're in a popup and the parent page is the page we're editing, then force a reload

            //$$$$ rename with querystring doesn't work
            OnPopupCloseEnum popupClose = OnPopupCloseEnum.ReloadModule;

            if (PageDefinition.IsSamePage(Manager.QueryReturnToUrl.Url, model.Page.Url))
            {
                popupClose = OnPopupCloseEnum.ReloadParentPage;
            }
            return(FormProcessed(model, this.__ResStr("okSaved", "Page settings saved"), OnPopupClose: popupClose));
        }