public ActionResult Create() { DataFetchContext dataFetchContext = new DataFetchContext(); ViewBag.HospitalRecord = dataFetchContext.Hospitals; ViewBag.SpecialtyRecord = dataFetchContext.Specialties; return View("Form",new Physician()); }
public ActionResult Edit(Guid id) { DataFetchContext dataFetchContext = new DataFetchContext(); var toEditRecord = dataFetchContext.Physicians.Single(x => x.ID == id); ViewBag.HospitalRecord = dataFetchContext.Hospitals; ViewBag.SpecialtyRecord = dataFetchContext.Specialties; return View("Form", toEditRecord); }
public ActionResult Edit(Physician a) { using (var context = new DataFetchContext()) { if(ModelState.IsValid) { context.Physicians.Attach(a); context.Entry<Physician>(a).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } else { DataFetchContext dataFetchContext = new DataFetchContext(); ViewBag.HospitalRecord = dataFetchContext.Hospitals; ViewBag.SpecialtyRecord = dataFetchContext.Specialties; return View("Form", a); } } }