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