コード例 #1
0
        public ActionResult Create(ProductSuppliers productsuppliers)
        {
            if (ModelState.IsValid)
            {
                db.ProductSuppliers.Add(productsuppliers);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.Product = new SelectList(db.Products, "Id", "Name", productsuppliers.Product);
            ViewBag.Supplier = new SelectList(db.Suppliers, "Id", "Name", productsuppliers.Supplier);
            return View(productsuppliers);
        }
コード例 #2
0
 public ActionResult Edit(ProductSuppliers productsuppliers)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productsuppliers).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.Product = new SelectList(db.Products, "Id", "Name", productsuppliers.Product);
     ViewBag.Supplier = new SelectList(db.Suppliers, "Id", "Name", productsuppliers.Supplier);
     return View(productsuppliers);
 }