protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
// // GET: /Paciente/Details/5 public ActionResult Details(int id) { ViewBag.Title = tituloCadastro; ViewBag.Method = "Detail"; ClinicaEntities db = new ClinicaEntities(); try { SelectListTelefones(db); Paciente paciente = db.Paciente.Find(id); CarregarAssociacoes(db, paciente); return(View("Create", paciente)); } finally { db.Dispose(); } }
// // GET: /Funcionario/Edit/5 public ActionResult Edit(int id) { ViewBag.Title = tituloCadastro; ViewBag.Method = "Edit"; ClinicaEntities db = new ClinicaEntities(); try { SelectListEspecialidades(db); SelectListTelefones(db); Funcionario func = db.Funcionario.Find(id); CarregarAssociacoes(db, func); return(View("Create", func)); } finally { db.Dispose(); } }
public ActionResult Edit(int id, Funcionario funcionario) { ViewBag.Title = tituloCadastro; try { ClinicaEntities db = new ClinicaEntities(); try { db.Entry(funcionario).State = System.Data.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } finally { db.Dispose(); } } catch (Exception e) { ViewBag.Error = e; return(View("Error")); } }