Ejemplo n.º 1
0
        /// <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 PostEditModel GetById(Guid id)
        {
            PostEditModel m = new PostEditModel() ;
            m.Template = PostTemplate.GetSingle(id) ;

            return m ;
        }
Ejemplo n.º 2
0
		/// <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 PostEditModel GetById(Guid id) {
			PostEditModel m = new PostEditModel() ;
			m.Template = PostTemplate.GetSingle(id) ;
			if (m.Template.Properties == null)
				m.Template.Properties = new List<string>() ;

			return m ;
		}
Ejemplo n.º 3
0
		/// <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 PostEditModel GetById(Guid id) {
			PostEditModel m = new PostEditModel() ;
			m.Template = PostTemplate.GetSingle(id) ;
			if (m.Template.Properties == null)
				m.Template.Properties = new List<string>() ;
			if (m.Template.PermalinkId != Guid.Empty)
				m.Permalink = Permalink.GetSingle(m.Template.PermalinkId) ;
			else m.Template.PermalinkId = m.Permalink.Id ;

			return m ;
		}
Ejemplo n.º 4
0
        /// <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 Post(string id = "")
        {
            PostEditModel m = new PostEditModel() ;

            if (id != "") {
                m = PostEditModel.GetById(new Guid(id)) ;
                ViewBag.Title = "Ändra artikeltyp" ;
            } else {
                ViewBag.Title = "Lägg till ny artikeltyp" ;
            }
            return View("PostEdit", m) ;
        }
Ejemplo n.º 5
0
        /// <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 PostEditModel GetById(Guid id)
        {
            PostEditModel m = new PostEditModel();

            m.Template = PostTemplate.GetSingle(id);
            if (m.Template.Properties == null)
            {
                m.Template.Properties = new List <string>();
            }
            if (m.Template.PermalinkId != Guid.Empty)
            {
                m.Permalink = Permalink.GetSingle(m.Template.PermalinkId);
            }
            else
            {
                m.Template.PermalinkId = m.Permalink.Id;
            }

            return(m);
        }
Ejemplo n.º 6
0
        public ActionResult Post(PostEditModel m)
        {
            ViewBag.Title = "Lägg till ny artikeltyp" ;

            if (ModelState.IsValid) {
                if (m.SaveAll()) {
                    ModelState.Clear() ;
                    ViewBag.Title = "Ändra artikeltyp" ;
                    ViewBag.Message = "Artikeltypen har sparats" ;
                } else ViewBag.Message = "Det gick inte att spara artikeltypen" ;
            }
            return View("PostEdit", m) ;
        }
Ejemplo n.º 7
0
		public ActionResult Post(PostEditModel m) {
			ViewBag.Title = Piranha.Resources.Template.EditPostTitleNew;

			if (ModelState.IsValid) {
				try {
					if (m.SaveAll()) {
						ModelState.Clear();
						ViewBag.Title = Piranha.Resources.Template.EditPostTitleExisting;
						SuccessMessage(Piranha.Resources.Template.MessagePostSaved);
					} else ErrorMessage(Piranha.Resources.Template.MessagePostNotSaved);
				} 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.Template.Name) == m.Permalink.Name)
						ModelState.Remove("Permalink.Name");
				} catch (Exception e) {
					ErrorMessage(e.ToString());
				}
			}
			return View("PostEdit", m);
		}
Ejemplo n.º 8
0
		public ActionResult Post(string id = "") {
			PostEditModel m = new PostEditModel();

			if (id != "") {
				m = PostEditModel.GetById(new Guid(id));
				ViewBag.Title = Piranha.Resources.Template.EditPostTitleExisting;
			} else {
				ViewBag.Title = Piranha.Resources.Template.EditPostTitleNew;
			}
			return View("PostEdit", m);
		}
Ejemplo n.º 9
0
        public ActionResult Post(PostEditModel m)
        {
            ViewBag.Title = Piranha.Resources.Template.EditPostTitleNew ;

            if (ModelState.IsValid) {
                if (m.SaveAll()) {
                    ModelState.Clear() ;
                    ViewBag.Title = Piranha.Resources.Template.EditPostTitleExisting ;
                    SuccessMessage(Piranha.Resources.Template.MessagePostSaved) ;
                } else ErrorMessage(Piranha.Resources.Template.MessagePostNotSaved) ;
            }
            return View("PostEdit", m) ;
        }