コード例 #1
0
        public ActionResult Create()
        {
            ModifyProductViewModel m = new ModifyProductViewModel();


            return(View(m));
        }
コード例 #2
0
 public ActionResult Edit(ModifyProductViewModel m)
 {
     if (ModelState.IsValid)
     {
         db.Entry(m.Product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(m.Product));
 }
コード例 #3
0
        public ActionResult Create(ModifyProductViewModel productViewModel)
        {
            if (ModelState.IsValid)
            {
                Guid guid = Guid.NewGuid();
                productViewModel.Product.ProductId = guid.ToString();
                db.Products.Add(productViewModel.Product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productViewModel));
        }