//Delete An Existing User
 public void DeleteUser(User user)
 {
     //MyDoctorDBContext DoctorDB = new MyDoctorDBContext();
     //User deletedUser = DoctorDB.Users.Where(u => u.ID == user.ID).FirstOrDefault();
     //DoctorDB.Users.Remove(deletedUser);
     //DoctorDB.SaveChanges();
     try
     {
         MyDoctorDBContext DoctorDB = new MyDoctorDBContext();
         User deletedUser           = DoctorDB.Users.Where(u => u.ID == user.ID).FirstOrDefault();
         DoctorDB.Users.Remove(deletedUser);
         DoctorDB.SaveChanges();
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
     {
         Exception raise = dbEx;
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 string message = string.Format("{0}:{1}",
                                                validationErrors.Entry.Entity.ToString(),
                                                validationError.ErrorMessage);
                 // raise a new exception nesting
                 // the current instance as InnerException
                 raise = new InvalidOperationException(message, raise);
             }
         }
         throw raise;
     }
 }
 //Update An Existing User
 public void UpdateUser(User newUser)
 {
     //MyDoctorDBContext DoctorDB = new MyDoctorDBContext();
     //DoctorDB.Entry(newUser).State = EntityState.Modified;
     //DoctorDB.SaveChanges();
     try
     {
         MyDoctorDBContext DoctorDB = new MyDoctorDBContext();
         DoctorDB.Entry(newUser).State = EntityState.Modified;
         DoctorDB.SaveChanges();
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
     {
         Exception raise = dbEx;
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 string message = string.Format("{0}:{1}",
                                                validationErrors.Entry.Entity.ToString(),
                                                validationError.ErrorMessage);
                 // raise a new exception nesting
                 // the current instance as InnerException
                 raise = new InvalidOperationException(message, raise);
             }
         }
         throw raise;
     }
 }
        //set Patient
        public void SetPatient(Patient patient)
        {
            //MyDoctorDBContext doctorDB = new MyDoctorDBContext();
            //doctorDB.Patients.Add(patient);
            //doctorDB.SaveChanges();

            try
            {
                MyDoctorDBContext DoctorDBContext = new MyDoctorDBContext();
                DoctorDBContext.Patients.Add(patient);
                DoctorDBContext.SaveChanges();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
        }
 //Delete An Existing Patient
 public void DeletePatient(int UserID)
 {
     //MyDoctorDBContext DoctorDB = new MyDoctorDBContext();
     //Patient deletedPatient = DoctorDB.Patients.Where(p => p.PatientID == PatientID).FirstOrDefault();
     //DoctorDB.Patients.Remove(deletedPatient);
     //DoctorDB.SaveChanges();
     try
     {
         MyDoctorDBContext DoctorDB = new MyDoctorDBContext();
         //get the patient
         Patient deletedPatient = DoctorDB.Patients.Where(p => p.PatientID == UserID).FirstOrDefault();
         if (deletedPatient != null)
         {
             //delete the patient
             DoctorDB.Patients.Remove(deletedPatient);
             DoctorDB.SaveChanges();
         }
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
     {
         Exception raise = dbEx;
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 string message = string.Format("{0}:{1}",
                                                validationErrors.Entry.Entity.ToString(),
                                                validationError.ErrorMessage);
                 // raise a new exception nesting
                 // the current instance as InnerException
                 raise = new InvalidOperationException(message, raise);
             }
         }
         throw raise;
     }
 }