示例#1
0
        public ActionResult Edit(bool draft, EditModel m)
        {
            if (ModelState.IsValid) {
                if (m.SaveAll(draft)) {
                    ModelState.Clear() ;
                    if (!draft)
                        ViewBag.Message = "Din artikel har publicerats." ;
                    else ViewBag.Message = "Din artikel har sparats." ;
                } else ViewBag.Message = "Artikeln kunde inte sparas." ;
            }
            m.Refresh() ;

            if (m.Post.IsNew)
                ViewBag.Title = "Lägg till " + m.Template.Name.Singular.ToLower() ;
            else ViewBag.Title = "Ändra " + m.Template.Name.Singular.ToLower() ;

            return View("Edit", m) ;
        }
示例#2
0
        public ActionResult Edit(bool draft, EditModel m)
        {
            if (ModelState.IsValid) {
                if (m.SaveAll(draft)) {
                    ModelState.Clear() ;
                    if (!draft)
                        SuccessMessage(Piranha.Resources.Post.MessagePublished) ;
                    else SuccessMessage(Piranha.Resources.Post.MessageSaved) ;
                } else ErrorMessage(Piranha.Resources.Post.MessageNotSaved) ;
            }
            m.Refresh() ;

            if (m.Post.IsNew)
                ViewBag.Title = Piranha.Resources.Post.EditTitleNew + m.Template.Name.ToLower() ;
            else ViewBag.Title = Piranha.Resources.Post.EditTitleExisting ;

            return View("Edit", m) ;
        }
示例#3
0
        public ActionResult Edit(bool draft, EditModel m)
        {
            if (ModelState.IsValid) {
                if (m.SaveAll(draft)) {
                    ModelState.Clear() ;
                    if (!draft)
                        SuccessMessage(Piranha.Resources.Post.MessagePublished) ;
                    else SuccessMessage(Piranha.Resources.Post.MessageSaved) ;
                } else ErrorMessage(Piranha.Resources.Post.MessageNotSaved) ;
            }
            m.Refresh() ;

            // Executes the post edit loaded hook, if registered
            if (WebPages.Hooks.Manager.PostEditModelLoaded != null)
                WebPages.Hooks.Manager.PostEditModelLoaded(this, WebPages.Manager.GetActiveMenuItem(), m) ;

            if (m.Post.IsNew)
                ViewBag.Title = Piranha.Resources.Post.EditTitleNew + m.Template.Name.ToLower() ;
            else ViewBag.Title = Piranha.Resources.Post.EditTitleExisting ;

            return View(@"~/Areas/Manager/Views/Post/Edit.cshtml", m) ;
        }
示例#4
0
		public ActionResult Edit(bool draft, EditModel m) {
			if (ModelState.IsValid) {
				try {
					if (m.SaveAll(draft)) {
						ModelState.Clear() ;
						if (!draft) {
							if (m.Post.Published == m.Post.LastPublished)
								SuccessMessage(Piranha.Resources.Post.MessagePublished, true) ;
							else SuccessMessage(Piranha.Resources.Post.MessageUpdated, true) ;
						} else SuccessMessage(Piranha.Resources.Post.MessageSaved, true) ;

						return RedirectToAction("edit", new { id = m.Post.Id, returl = ViewBag.ReturnUrl }) ;
					} else ErrorMessage(Piranha.Resources.Post.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(m.Post.Title) == m.Permalink.Name)
						ModelState.Remove("Permalink.Name") ;
				} catch (Exception e) {
					ErrorMessage(e.ToString()) ;
				}
			}
			m.Refresh() ;

			// Executes the post edit loaded hook, if registered
			if (WebPages.Hooks.Manager.PostEditModelLoaded != null)
				WebPages.Hooks.Manager.PostEditModelLoaded(this, WebPages.Manager.GetActiveMenuItem(), m) ;

			if (m.Post.IsNew)
				ViewBag.Title = Piranha.Resources.Post.EditTitleNew + m.Template.Name.ToLower() ;
			else ViewBag.Title = Piranha.Resources.Post.EditTitleExisting ;

			return View(@"~/Areas/Manager/Views/Post/Edit.cshtml", m) ;
		}