public ActionResult UpdatePatient(int id) { //Get the patient from database based on the selected doctor id var objPatient = objPat.getPatientByID(id); if (objPatient == null) { return View("NotFound"); } else { UpdatePatientModel objUpPat = new UpdatePatientModel(); objUpPat.health_card = objPatient.health_card; objUpPat.first_name = objPatient.first_name; objUpPat.last_name = objPatient.last_name; objUpPat.birth_date = objPatient.birth_date; objUpPat.gender = objPatient.gender; objUpPat.email = objPatient.email; objUpPat.phone = objPatient.phone; objUpPat.address = objPatient.address; objUpPat.city = objPatient.city; objUpPat.province = objPatient.province; objUpPat.postal_code = objPatient.postal_code; return View(objUpPat); } }
public ActionResult UpdatePatient(int id, UpdatePatientModel model) { if (ModelState.IsValid) { try { riversideLinqDataContext objLinq = new riversideLinqDataContext(); patient objPatient = objLinq.patients.Single(x => x.id == id); objPatient.health_card = model.health_card; objPatient.first_name = model.first_name; objPatient.last_name = model.last_name; objPatient.birth_date = model.birth_date; objPatient.gender = model.gender; objPatient.email = model.email; objPatient.phone = model.phone; objPatient.address = model.address; objPatient.city = model.city; objPatient.province = model.province; objPatient.postal_code = model.postal_code; objLinq.SubmitChanges(); return RedirectToAction("PatientProfile"); } catch { return View(model); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult UpdatePatient(int id, UpdatePatientModel model) { ViewBag.patientId = id; if (ModelState.IsValid) { try { riversideLinqDataContext objLinq = new riversideLinqDataContext(); patient objPatient = objLinq.patients.Single(x => x.id == id); objPatient.health_card = model.health_card; objPatient.first_name = model.first_name; objPatient.last_name = model.last_name; objPatient.birth_date = model.birth_date; objPatient.gender = model.gender; objPatient.email = model.email; objPatient.phone = model.phone; objPatient.address = model.address; objPatient.city = model.city; objPatient.province = model.province; objPatient.postal_code = model.postal_code; objLinq.SubmitChanges(); //return RedirectToAction("PatientDetail/" + id); return RedirectToAction("ListPatient"); } catch { return View(model); } } return View(model); }