/* * This method make a form for * input new dates of product in Salvar method */ public ActionResult Cadastrar() { CategoryDao dao = CategoryDao.GetInstance(); IList <Category> categories = dao.ListAll(); return(View(categories)); }
public ActionResult Salvar(Product product) { ProductDao productDao = ProductDao.GetInstance(); product.Category = CategoryDao.GetInstance().GetById(product.Category.Id); /* cadastrar */ if (product.Id == 0) { productDao.Add(product); return(RedirectToAction("Index", "Product")); } /* Editar */ else { productDao.Update(product); return(RedirectToAction("Index", "Product")); } }