public ActionResult Insurance(EditPatientInsuranceModel insuranceInfo) { if (ModelState.IsValid) { Patient patient = db.Patients.Find(insuranceInfo.UserId); patient.InsuranceCompany = db.InsuranceCompanies.Find(insuranceInfo.InsuranceCompanyID); patient.InsurancePolicy = db.InsurancePolicies.Find(insuranceInfo.InsurancePolicyID); patient.InsuranceExpiryDate = insuranceInfo.InsuranceExpiryDate; patient.InsurancePolicyNumber = insuranceInfo.InsurancePolicyNumber; db.Entry(patient).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(insuranceInfo); }
// // GET: /Patient/Insurance/5 public ActionResult Insurance(int id = 0) { Patient patient = db.Patients.Find(id); if (patient == null) { return HttpNotFound(); } var insuranceInfo = new EditPatientInsuranceModel(patient); insuranceInfo.InsuranceCompanies = new SelectList( db.InsuranceCompanies, "InsuranceCompanyID", "CompanyName", db.InsuranceCompanies.First()); insuranceInfo.InsurancePolicies = new SelectList( db.InsurancePolicies, "InsurancePolicyID", "PolicyName", db.InsurancePolicies.First()); return View(insuranceInfo); }