Beispiel #1
0
        public ActionResult Edit(CategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                Category category = new Category { Name = model.Name, CategoryId = model.Id };
                db.AddCategory(category);

                return RedirectToAction("Index", "Home");
            }

            return View(model);
        }
Beispiel #2
0
 public ActionResult Edit(int id)
 {
     Category category = db.Categories.Single(c => c.CategoryId == id);
     CategoryViewModel model = new CategoryViewModel { Id = id, Name = category.Name };
     return View(model);
 }