예제 #1
0
        public ActionResult Create(Laptop laptop)
        {
            if (ModelState.IsValid)
            {
                db.Laptops.Add(laptop);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.ManufacturerId = new SelectList(db.Manufacturers, "Id", "Name", laptop.ManufacturerId);
            return View(laptop);
        }
예제 #2
0
 public ActionResult Edit(Laptop laptop)
 {
     if (ModelState.IsValid)
     {
         db.Entry(laptop).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.ManufacturerId = new SelectList(db.Manufacturers, "Id", "Name", laptop.ManufacturerId);
     return View(laptop);
 }