public ActionResult Edit(long? id) { EditCategoryViewModel view = new EditCategoryViewModel { Category = _service.GetCategory(id ?? 0) }; return View(view); }
public ActionResult Create() { EditCategoryViewModel view = new EditCategoryViewModel { Category = new CategoryModel() }; return View("edit", view); }
public ActionResult Edit(CategoryModel model) { if(ModelState.IsValid) { long id = _service.SaveCategory(model); return RedirectToAction("view", "category", new { id = id }); } EditCategoryViewModel view = new EditCategoryViewModel { Category = model }; return View(view); }