Exemple #1
0
        /*
         * 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));
        }
Exemple #2
0
        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"));
            }
        }