Example #1
0
 //
 // GET: /Add/
 public ActionResult Add(int id = 0)
 {
     var model = new Category();
     var list = CategoryService.GetList();
     ViewData["Parent"] = new SelectList(list, "ID", "Name");
     if (id > 0)
     {
         model = CategoryService.Get(id);
     }
     return View(model);
 }
Example #2
0
 public ActionResult Add(Category category)
 {
     if (ModelState.IsValid)
     {
         if (category.ID != 0)
         {
             CategoryService.Update(category);
         }
         else
         {
             CategoryService.Add(category);
         }
         return RedirectToAction("List");
     }
     return View(category);
 }