/// <summary> /// Gets the model for the template specified by the given id. /// </summary> /// <param name="id">The template id</param> /// <returns>The model</returns> public static PageEditModel GetById(Guid id) { PageEditModel m = new PageEditModel() ; m.Template = PageTemplate.GetSingle(id) ; return m ; }
/// <summary> /// Gets the model for the template specified by the given id. /// </summary> /// <param name="id">The template id</param> /// <returns>The model</returns> public static PageEditModel GetById(Guid id) { PageEditModel m = new PageEditModel() ; m.Template = PageTemplate.GetSingle(id) ; m.Regions = RegionTemplate.Get("regiontemplate_template_id = @0", id, new Params() { OrderBy = "regiontemplate_seqno" }) ; return m ; }
/// <summary> /// Extend the default binder so that html strings can be fetched from the post. /// </summary> /// <param name="controllerContext">Controller context</param> /// <param name="bindingContext">Binding context</param> /// <returns>The page edit model</returns> public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { PageEditModel model = (PageEditModel)base.BindModel(controllerContext, bindingContext) ; bindingContext.ModelState.Remove("Template.Preview") ; model.Template.Preview = new HtmlString(bindingContext.ValueProvider.GetUnvalidatedValue("Template.Preview").AttemptedValue) ; return model ; }
public ActionResult Page(PageEditModel m) { //if (ModelState.IsValid) { if (m.SaveAll()) { ModelState.Clear() ; ViewBag.Message = "Mallen har sparats" ; } //} return View("PageEdit", m) ; }
public ActionResult Page(string id = "") { PageEditModel m = new PageEditModel(); if (id != "") { m = PageEditModel.GetById(new Guid(id)); ViewBag.Title = Piranha.Resources.Template.EditPageTitleExisting; } else { ViewBag.Title = Piranha.Resources.Template.EditPageTitleNew; } return View("PageEdit", m); }
/// <summary> /// Gets the model for the template specified by the given id. /// </summary> /// <param name="id">The template id</param> /// <param name="loadRegionTypes">If the region types should be loaded</param> /// <returns>The model</returns> public static PageEditModel GetById(Guid id, bool loadRegionTypes = true) { PageEditModel m = new PageEditModel(loadRegionTypes); m.Template = PageTemplate.GetSingle(id); m.Regions = RegionTemplate.Get("regiontemplate_template_id = @0", id, new Params() { OrderBy = "regiontemplate_seqno" }); return(m); }
/// <summary> /// Opens the insert or edit view for the template depending on /// weather a template id was passed to the action. /// </summary> /// <param name="id">The template id</param> public ActionResult Page(string id = "") { PageEditModel m = new PageEditModel() ; if (id != "") { m = PageEditModel.GetById(new Guid(id)) ; ViewBag.Title = "Ändra sidmall" ; } else { ViewBag.Title = "Lägg till ny sidmall" ; } return View("PageEdit", m) ; }
public ActionResult Page(PageEditModel m) { if (ModelState.IsValid) { if (m.SaveAll()) { ModelState.Clear(); ViewBag.Title = Piranha.Resources.Template.EditPageTitleExisting; SuccessMessage(Piranha.Resources.Template.MessagePageSaved); } else ErrorMessage(Piranha.Resources.Template.MessagePageNotSaved); } else { if (m.Template.IsNew) ViewBag.Title = Piranha.Resources.Template.EditPageTitleNew; else ViewBag.Title = Piranha.Resources.Template.EditPageTitleExisting; } return View("PageEdit", m); }