private void SavePatientAddressData(object parameter) { DataLayer.DB_SERVER db = new DataLayer.DB_SERVER(); var patientAddressInDB = db.Address.FirstOrDefault(e => e.PatientId == PatientId); if (patientAddressInDB != null) { patientAddressInDB.Address1 = Address1; patientAddressInDB.Address2 = Address2; patientAddressInDB.PostalCode = PostalCode; patientAddressInDB.City = City; db.SaveChanges(); } else { db.Address.Add(new tAddress { PatientId = PatientId, Address1 = Address1, Address2 = Address2, PostalCode = PostalCode, City = City }); db.SaveChanges(); } var commandParameter = Convert.ToInt16(parameter); if (commandParameter != null && commandParameter != 0) //save and previous tab { if (SaveAndNextTabAction != null) { SaveAndNextTabAction.Invoke(); } } }
private void SavePatientData(object parameter) { bool newlyAdd = PatientId == 0 ? true : false; // DoctorId = _DoctorId; var patient = new tPatient { PatientId = PatientId, FirstName = FirstName, LastName = LastName, DOB = DOB, SSN = SSN, DoctorId = DoctorId }; DataLayer.DB_SERVER db = new DataLayer.DB_SERVER(); if (newlyAdd) { db.Patient.Add(patient); db.SaveChanges(); PatientId = patient.PatientId; } else { var patientInDB = db.Patient.FirstOrDefault(e => e.PatientId == PatientId); if (patientInDB != null) { patientInDB.FirstName = FirstName; patientInDB.LastName = LastName; patientInDB.DOB = DOB; patientInDB.SSN = SSN; patientInDB.DoctorId = DoctorId; db.SaveChanges(); } } if (newlyAdd) { if (PatentInsertedAction != null) { PatentInsertedAction(PatientId); } } var commandParameter = Convert.ToInt16(parameter); if (commandParameter != null && commandParameter != 0) //save and next tab { if (SaveAndNextTabAction != null) { SaveAndNextTabAction.Invoke(); } } }