Example #1
0
 public void Add(T item)
 {
     using (var context = new ClinicDbContext())
     {
         context.Set <T>().Add(item);
         context.SaveChanges();
     }
 }
 public void Add(string doctorName, DateTime startDateTime)
 {
     using (var context = new ClinicDbContext())
     {
         var doctor = context.Doctors.Single(d => d.Name == doctorName);
         context.Appointments.Add(new Appointment {
             Doctor = doctor, StartDate = startDateTime
         });
         context.SaveChanges();
     }
 }
Example #3
0
 public void Add(string doctorName, string officeLocation, DayOfWeek dayOfWeek, TimeSpan startTime, TimeSpan endTime)
 {
     using (var context = new ClinicDbContext())
     {
         var doctor = context.Doctors.Single(d => d.Name == doctorName);
         var office = context.Offices.Single(o => o.Location == officeLocation);
         context.OfficeHours.Add(new OfficeHours
         {
             Doctor    = doctor,
             Office    = office,
             DayOfWeek = dayOfWeek,
             StartTime = startTime,
             EndTime   = endTime
         });
         context.SaveChanges();
     }
 }
 public void Add(string doctorName, string officeLocation, string patientName, DateTime startDateTime, DateTime endDateTime, decimal amountReceived)
 {
     using (var context = new ClinicDbContext())
     {
         var doctor  = context.Doctors.Single(d => d.Name == doctorName);
         var office  = context.Offices.Single(d => d.Location == officeLocation);
         var patient = context.Patients.Single(d => d.Name == patientName);
         context.Examinations.Add(new Examination
         {
             Doctor         = doctor,
             Office         = office,
             Patient        = patient,
             StartDateTime  = startDateTime,
             EndDateTime    = endDateTime,
             AmountReceived = amountReceived
         });
         context.SaveChanges();
     }
 }