Example #1
0
        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);
        }
Example #2
0
 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);
 }