public ActionResult Edit(Patient patient, int DoctorId) { bool unique = true; List <DoctorPatient> doctorList = _db.Patients .Where(i => i.PatientId == patient.PatientId) .Select(i => i.Doctors).ToList()[0].ToList(); foreach (DoctorPatient doctorPatient in doctorList) { if (doctorPatient.DoctorId == DoctorId) { unique = false; } } if (DoctorId != 0 && unique) { _db.DoctorPatient.Add(new DoctorPatient() { DoctorId = DoctorId, PatientId = patient.PatientId }); } _db.Entry(patient).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Specialty specialty, int DoctorId) { if (DoctorId != 0) { _db.DoctorPatientSpecialty.Add(new DoctorPatientSpecialty() { DoctorId = DoctorId, SpecialtyId = specialty.SpecialtyId }); } _db.Entry(specialty).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", new { id = specialty.SpecialtyId })); }
public ActionResult Edit(Patient patient, int DoctorId) { if (DoctorId != 0) { _db.DoctorPatient.Add(new DoctorPatient() { DoctorId = DoctorId, PatientId = patient.PatientId }); } _db.Entry(patient).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Doctor doctor, int SpecialtyId) { if (SpecialtyId != 0) { _db.DoctorSpecialty.Add(new DoctorSpecialty() { SpecialtyId = SpecialtyId, DoctorId = doctor.DoctorId }); } _db.Entry(doctor).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Doctor doctor) { try { _db.Entry(doctor).State = EntityState.Modified; _db.SaveChanges(); } catch (Exception ex) { TempData["ErrorMessage"] = "An Error occurred. Please see the Console for details."; Console.WriteLine("Exception Error in Edit(): " + ex); } return(RedirectToAction("Index")); }
public ActionResult Edit(Doctor doctor, int patientId) { //check if doctor already has patient bool match = _db.DoctorPatient.Any(join => join.PatientId == patientId && join.DoctorId == doctor.DoctorId); if (patientId != 0 && match == false) { _db.DoctorPatient.Add(new DoctorPatient { DoctorId = doctor.DoctorId, PatientId = patientId }); } _db.Entry(doctor).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Patient patient, int doctorId) { bool match = _db.DoctorPatient.Any(join => join.DoctorId == doctorId && join.PatientId == patient.PatientId); if (doctorId != 0 && match == false) { _db.DoctorPatient.Add(new DoctorPatient() { DoctorId = doctorId, PatientId = patient.PatientId }); } _db.Entry(patient).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Doctor doctor, int PatientId, int SpecialtyId) { if (PatientId != 0) { _db.DoctorPatientSpecialty.Add(new DoctorPatientSpecialty() { PatientId = PatientId, DoctorId = doctor.DoctorId }); } if (SpecialtyId != 0) { _db.DoctorPatientSpecialty.Add(new DoctorPatientSpecialty() { SpecialtyId = SpecialtyId, DoctorId = doctor.DoctorId }); } _db.Entry(doctor).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", new { id = doctor.DoctorId })); }
public ActionResult Edit(Doctor doctor) { _db.Entry(doctor).State = EntityState.Modified; _db.SaveChanges(); return RedirectToAction("Index"); }