Exemple #1
0
 public ActionResult Edit(ProductEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         var product = model.GetProduct();
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Exemple #2
0
        public ActionResult Create(ProductEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var product = model.GetProduct();
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }