public ActionResult Create(Maintenance maintenance) { if (ModelState.IsValid) { db.Maintenances.Add(maintenance); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CarID = new SelectList(db.Cars, "CarID", "Nickname", maintenance.CarID); ViewBag.JobID = new SelectList(db.Jobs, "JobID", "JobDescr", maintenance.JobID); return View(maintenance); }
public ActionResult Edit(Maintenance maintenance) { if (ModelState.IsValid) { db.Entry(maintenance).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CarID = new SelectList(db.Cars, "CarID", "Nickname", maintenance.CarID); ViewBag.JobID = new SelectList(db.Jobs, "JobID", "JobDescr", maintenance.JobID); return View(maintenance); }