public ActionResult Edit(bool draft, EditModel pm) { if (ModelState.IsValid) { try { if (pm.SaveAll(draft)) { ModelState.Clear() ; if (!draft) SuccessMessage(Piranha.Resources.Page.MessagePublished) ; else SuccessMessage(Piranha.Resources.Page.MessageSaved) ; } else ErrorMessage(Piranha.Resources.Page.MessageNotSaved) ; } catch (DuplicatePermalinkException e) { // Manually set the duplicate error. ModelState.AddModelError("Permalink", @Piranha.Resources.Global.PermalinkDuplicate) ; // If this is the default permalink, remove the model state so it will be shown. if (Permalink.Generate(pm.Page.Title) == pm.Permalink.Name) ModelState.Remove("Permalink.Name") ; } catch (Exception e) { ErrorMessage(e.ToString()) ; } } pm.Refresh(); if (pm.Page.IsNew) ViewBag.Title = Piranha.Resources.Page.EditTitleNew + pm.Template.Name.ToLower() ; else ViewBag.Title = Piranha.Resources.Page.EditTitleExisting ; return View("Edit", pm) ; }
public ActionResult Edit(bool draft, EditModel pm) { if (ModelState.IsValid) { try { if (pm.SaveAll(draft)) { ModelState.Clear() ; if (!draft) SuccessMessage(Piranha.Resources.Page.MessagePublished) ; else SuccessMessage(Piranha.Resources.Page.MessageSaved) ; } else ErrorMessage(Piranha.Resources.Page.MessageNotSaved) ; } catch (Exception e) { ErrorMessage(e.ToString()) ; } } pm.Refresh(); if (pm.Page.IsNew) ViewBag.Title = Piranha.Resources.Page.EditTitleNew + pm.Template.Name.ToLower() ; else ViewBag.Title = Piranha.Resources.Page.EditTitleExisting ; return View("Edit", pm) ; }
public ActionResult Edit(bool draft, EditModel pm) { if (ModelState.IsValid) { try { // Executes the page edit before save hook, if registered if (WebPages.Hooks.Manager.PageEditModelBeforeSave != null) WebPages.Hooks.Manager.PageEditModelBeforeSave(this, WebPages.Manager.GetActiveMenuItem(), pm) ; if (pm.SaveAll(draft)) { // Executes the page edit after save hook, if registered if (WebPages.Hooks.Manager.PageEditModelAfterSave != null) WebPages.Hooks.Manager.PageEditModelAfterSave(this, WebPages.Manager.GetActiveMenuItem(), pm) ; ModelState.Clear() ; if (!draft) { if (pm.Page.Published == pm.Page.LastPublished) SuccessMessage(Piranha.Resources.Page.MessagePublished) ; else SuccessMessage(Piranha.Resources.Page.MessageUpdated) ; } else SuccessMessage(Piranha.Resources.Page.MessageSaved) ; } else ErrorMessage(Piranha.Resources.Page.MessageNotSaved) ; } catch (DuplicatePermalinkException) { // Manually set the duplicate error. ModelState.AddModelError("Permalink", @Piranha.Resources.Global.PermalinkDuplicate) ; // If this is the default permalink, remove the model state so it will be shown. if (Permalink.Generate(pm.Page.Title) == pm.Permalink.Name) ModelState.Remove("Permalink.Name") ; } catch (Exception e) { ErrorMessage(e.ToString()) ; } } pm.Refresh(); // Executes the page list loaded hook, if registered if (WebPages.Hooks.Manager.PageEditModelLoaded != null) WebPages.Hooks.Manager.PageEditModelLoaded(this, WebPages.Manager.GetActiveMenuItem(), pm) ; if (!pm.IsSite) { if (pm.Page.IsNew) ViewBag.Title = Piranha.Resources.Page.EditTitleNew + pm.Template.Name.ToLower() ; else ViewBag.Title = Piranha.Resources.Page.EditTitleExisting ; } else ViewBag.Title = Piranha.Resources.Global.Edit + " " + pm.SiteTree.Name.ToLower() ; if (pm.Page.OriginalId != Guid.Empty) return View(@"~/Areas/Manager/Views/Page/EditCopy.cshtml", pm) ; return View(@"~/Areas/Manager/Views/Page/Edit.cshtml", pm) ; }