Exemplo n.º 1
0
 /// <summary>
 /// Delete an object in database.
 /// </summary>
 /// <param name="patient"></param>
 /// <returns>An object of type Patient.</returns>
 public Patient DeletePatient(Patient patient)
 {
     using (HolmuskHealthCareEntities context = new HolmuskHealthCareEntities())
     {
         var existingPatient = context.Patients.Where(p => p.Id == patient.Id).FirstOrDefault <Patient>();
         if (existingPatient != null)
         {
             existingPatient.IsActive = patient.IsActive;
         }
         context.SaveChanges();
         return(patient);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adds an object to database.
 /// </summary>
 /// <param name="patient"></param>
 /// <returns>An object of type Patient.</returns>
 public Patient AddPatient(Patient patient)
 {
     using (HolmuskHealthCareEntities context = new HolmuskHealthCareEntities())
     {
         var existingPatient = context.Patients.Where(p => p.Name == patient.Name && patient.ContactNumber == patient.ContactNumber && p.BirthDate == patient.BirthDate).FirstOrDefault <Patient>();
         if (existingPatient == null)
         {
             context.Patients.Add(patient);
             context.SaveChanges();
         }
         return(patient);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Modify an object in database.
 /// </summary>
 /// <param name="patient"></param>
 /// <returns>An object of type Patient.</returns>
 public Patient UpdatePatient(Patient patient)
 {
     using (HolmuskHealthCareEntities context = new HolmuskHealthCareEntities())
     {
         var existingPatient = context.Patients.Where(p => p.Id == patient.Id).FirstOrDefault <Patient>();
         if (existingPatient != null)
         {
             existingPatient.Name          = patient.Name;
             existingPatient.Address       = patient.Address;
             existingPatient.BirthDate     = patient.BirthDate;
             existingPatient.ContactNumber = patient.ContactNumber;
             existingPatient.Gender        = patient.Gender;
             existingPatient.IsActive      = patient.IsActive;
         }
         context.SaveChanges();
         return(patient);
     }
 }