示例#1
0
 public ActionResult Create()
 {
     DataFetchContext dataFetchContext = new DataFetchContext();
     ViewBag.HospitalRecord = dataFetchContext.Hospitals;
     ViewBag.SpecialtyRecord = dataFetchContext.Specialties;
     return View("Form",new Physician());
 }
示例#2
0
 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);
 }
示例#3
0
 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);
         }
     }
 }