Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
 public virtual ActionResult CreateCategoryAttribute(int categoryId)
 {
     var model = new CategoryAttributeForm {CategoryId = categoryId};
     return View(model);
 }