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); }
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); }