Exemplo n.º 1
0
 public ActionResult Create()
 {
     var model = new CategoryViewModel
     {
          Categories = ProductManager.GetCategoriesSelectList()
     };
     return View(model);
 }
Exemplo n.º 2
0
        public ActionResult Create(CategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                var category = new ProductCategory
                {
                     Name = model.Name,
                     NameShort = model.NameShort,
                     ParentId = model.ParentId
                };
                ProductManager.CreateCategory(category);
                ProductManager.Save();

                return RedirectToAction("Index");
            }
            return View(model);
        }
Exemplo n.º 3
0
 public ActionResult Update(Guid? id)
 {
     if (id.HasValue)
     {
         var entity = ProductManager.FindCategoryById(id.Value);
         var model = new CategoryViewModel
         {
             Id = entity.Id,
             Name = entity.Name,
             NameShort = entity.NameShort,
             ParentId = entity.ParentId,
             Categories = ProductManager.GetCategoriesSelectList()
         };
         return View("Update", model);
     }
     return RedirectToAction("Index");
 }