public ActionResult Edit(Doctor doctor) { if(ModelState.IsValid) { db.Entry(doctor).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.IDCity = new SelectList(db.Cities, "IDCity", "Name", doctor.IDCity); ViewBag.IDSpecialty = new SelectList(db.Specialties, "IDSpecialty", "Name", doctor.IDSpecialty); return View(doctor); }
public ActionResult Create(Doctor doctor) { if(ModelState.IsValid) { db.Doctors.Add(doctor); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.IDCity = new SelectList(db.Cities, "IDCity", "Name"); ViewBag.IDSpecialty = new SelectList(db.Specialties, "IDSpecialty", "Name"); return View(doctor); }