示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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();
            }
        }