예제 #1
0
        public ActionResult Save(Product products)
        {
            if (!ModelState.IsValid)
            {
                return(View("CreateProduct"));
            }

            try
            {
                if (products == null)
                {
                    return(View("CreateProduct"));
                }


                if (products.Id == 0)
                {
                    _productApplication.Register(products);
                }
                else
                {
                    _productApplication.Update(products);
                }


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("CreateProduct"));
            }
        }
예제 #2
0
 public ActionResult Create(Product product)
 {
     if (ModelState.IsValid)
     {
         _productApplication.Register(product);
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }