public ActionResult Create(MModel mmodel) { if (ModelState.IsValid) { db.MModels.Add(mmodel); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryId = new SelectList(db.Categories, "ID", "CategoryName", mmodel.CategoryId); ViewBag.ManufacturerId = new SelectList(db.Manufacturers, "ID", "ManufacturerName", mmodel.ManufacturerId); return View(mmodel); }
public ActionResult Edit(MModel mmodel) { if (ModelState.IsValid) { db.Entry(mmodel).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryId = new SelectList(db.Categories, "ID", "CategoryName", mmodel.CategoryId); ViewBag.ManufacturerId = new SelectList(db.Manufacturers, "ID", "ManufacturerName", mmodel.ManufacturerId); return View(mmodel); }