Esempio n. 1
0
		/// <summary>
		/// Gets the edit model for the category with the given id.
		/// </summary>
		/// <param name="id">The category id</param>
		/// <returns>The model</returns>
		public static EditModel GetById(Guid id) {
			EditModel m = new EditModel() {
				Category = Category.GetSingle(id)
			} ;
			m.GetRelated() ;

			return m ;
		}
Esempio n. 2
0
        /// <summary>
        /// Gets the edit model for the category with the given id.
        /// </summary>
        /// <param name="id">The category id</param>
        /// <returns>The model</returns>
        public static EditModel GetById(Guid id)
        {
            EditModel m = new EditModel()
            {
                Category = Category.GetSingle(id)
            };

            m.GetRelated();

            return(m);
        }
Esempio n. 3
0
		public ActionResult Edit(string id = "") {
			EditModel m = new EditModel() ;

			if (id != "") {
				m = EditModel.GetById(new Guid(id)) ;
				ViewBag.Title = Piranha.Resources.Category.EditTitleExisting ;
			} else {
				ViewBag.Title = Piranha.Resources.Category.EditTitleNew ;
			}
			return View("Edit", m) ;
		}
Esempio n. 4
0
        /// <summary>
        /// Edits or inserts a new category.
        /// </summary>
        /// <param name="id">The category id</param>
        public ActionResult Edit(string id = "")
        {
            EditModel m = new EditModel() ;

            if (id != "") {
                m = EditModel.GetById(new Guid(id)) ;
                ViewBag.Title = "Ändra kategori" ;
            } else {
                ViewBag.Title = "Lägg till ny kategori" ;
            }
            return View("Edit", m) ;
        }
Esempio n. 5
0
		public ActionResult Edit(EditModel m) {
			if (ModelState.IsValid) {
				if (m.SaveAll()) {
					ViewBag.Title = Piranha.Resources.Category.EditTitleExisting ;
					SuccessMessage(Piranha.Resources.Category.MessageSaved) ;
					ModelState.Clear() ;
				} else {
					ViewBag.Title = Piranha.Resources.Category.EditTitleNew ;
					ErrorMessage(Piranha.Resources.Category.MessageNotSaved) ;
				}
			}
			return View("Edit", m) ;
		}
Esempio n. 6
0
        /// <summary>
        /// Gets the edit model for the category with the given id.
        /// </summary>
        /// <param name="id">The category id</param>
        /// <returns>The model</returns>
        public static EditModel GetById(Guid id)
        {
            EditModel m = new EditModel() {
                Category = Category.GetSingle(id),
                Permalink = Permalink.GetByParentId(id)
            } ;

            List<Category> cats = Piranha.Models.Category.Get("category_id != @0", id,
                new Params() { OrderBy = "category_name ASC" }) ;
            cats.Insert(0, new Category()) ;
            m.Categories = new SelectList(cats, "Id", "Name") ;

            return m ;
        }
Esempio n. 7
0
 public ActionResult Edit(EditModel m)
 {
     if (ModelState.IsValid) {
         if (m.SaveAll()) {
             ViewBag.Title = "Ändra kategori" ;
             ViewBag.Message = "Din kategori har sparats." ;
             ModelState.Clear() ;
         } else {
             ViewBag.Title = "Lägg till kategori" ;
             ViewBag.Message = "Din kategori kunde inte sparas." ;
         }
     }
     return View("Edit", m) ;
 }
Esempio n. 8
0
            /// <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)
            {
                EditModel model = (EditModel)base.BindModel(controllerContext, bindingContext);

                // Allow HtmlString extensions
                model.Extensions.Each((i, m) => {
                    if (m.Body is HtmlString)
                    {
                        bindingContext.ModelState.Remove("Extensions[" + i + "].Body");
                        m.Body = App.Instance.ExtensionManager.CreateInstance(m.Type,
                                                                              bindingContext.ValueProvider.GetUnvalidatedValue("Extensions[" + i + "].Body").AttemptedValue);
                    }
                });
                return(model);
            }
Esempio n. 9
0
		public ActionResult Edit(EditModel m) {
			if (ModelState.IsValid) {
				// Executes the category edit before save hook, if registered
				if (WebPages.Hooks.Manager.CategoryEditModelBeforeSave != null)
					WebPages.Hooks.Manager.CategoryEditModelBeforeSave(this, WebPages.Manager.GetActiveMenuItem(), m);

				if (m.SaveAll()) {
					// Executes the category edit before save hook, if registered
					if (WebPages.Hooks.Manager.CategoryEditModelAfterSave != null)
						WebPages.Hooks.Manager.CategoryEditModelAfterSave(this, WebPages.Manager.GetActiveMenuItem(), m);

					ViewBag.Title = Piranha.Resources.Category.EditTitleExisting;
					SuccessMessage(Piranha.Resources.Category.MessageSaved);
					ModelState.Clear();
				} else {
					ViewBag.Title = Piranha.Resources.Category.EditTitleNew;
					ErrorMessage(Piranha.Resources.Category.MessageNotSaved);
				}
			}
			return View("Edit", m);
		}