private DbPatient GetDbPatient(PatientModelContainer context, string lastName) { DbPatient dbPatientFound = null; dbPatientFound = (from p in context.DbPatients where p.LastName == lastName select p).FirstOrDefault(); return(dbPatientFound); }
private Patient GetPatientFromDbPatient(DbPatient dbPatient) { var person = new Patient() { FirstName = dbPatient.FirstName, LastName = dbPatient.LastName, PhoneNumber = dbPatient.PhoneNumber, MobileNumber = dbPatient.MobileNumber, Address = dbPatient.Address }; return(person); }
public void AddPatient(Patient newPatient) { using (var context = new PatientModelContainer()) { if (GetDbPatient(context, newPatient.LastName) != null) { return; } var addPatient = new DbPatient() { FirstName = newPatient.FirstName, LastName = newPatient.LastName, PhoneNumber = newPatient.PhoneNumber, MobileNumber = newPatient.MobileNumber, Address = newPatient.Address }; context.DbPatients.Add(addPatient); context.SaveChanges(); } }