public virtual ActionResult EditCategoryAttribute(CategoryAttributeForm form) { if (!ModelState.IsValid) return View(form); var attribute = Repository.Category.GetCategoryAttribute(form.AttributeId); attribute.ParentOptions.Clear(); Mapper.Map(form, attribute); Repository.Category.UpdateCategoryAttribute(attribute); Flash.Success(Resources.Administration.CategoryAttributeUpdated); return RedirectToAction(MVC.Administration.CategoryList()); }
public virtual ActionResult CreateChildCategoryAttribute(int parentCategoryAttributeId) { var parentAttribute = Repository.Category.GetCategoryAttribute(parentCategoryAttributeId); var model = new CategoryAttributeForm { ParentAttributeId = parentCategoryAttributeId, AvailableParentOptions = parentAttribute.Options }; return View(MVC.Administration.Views.CreateCategoryAttribute, model); }
public virtual ActionResult CreateCategoryAttribute(CategoryAttributeForm form) { if (!ModelState.IsValid) return View(form); var categoryAttribute = Mapper.Map<CategoryAttribute>(form); if (form.ParentAttributeId.HasValue) { var parentAttribute = Repository.Category.GetCategoryAttribute(form.ParentAttributeId.Value); parentAttribute.ChildAttributes.Add(categoryAttribute); Repository.Category.UpdateCategoryAttribute(parentAttribute); } else { var category = Repository.Category.Get(form.CategoryId); category.Attributes.Add(categoryAttribute); Repository.Category.Update(category); } Flash.Success(Resources.Administration.CategoryAttributeCreated); if (form.Type == CategoryAttributeType.SingleSelect || form.Type == CategoryAttributeType.MultiSelect) return RedirectToAction(MVC.Administration.EditCategoryAttribute(categoryAttribute.Id, form.ParentAttributeId)); return RedirectToAction(MVC.Administration.CategoryList()); }
public virtual ActionResult CreateCategoryAttribute(int categoryId) { var model = new CategoryAttributeForm {CategoryId = categoryId}; return View(model); }