コード例 #1
0
ファイル: Repository.cs プロジェクト: mihaistancu/Clinic
 public virtual List <T> GetAll()
 {
     using (var context = new ClinicDbContext())
     {
         return(context.Set <T>().ToList());
     }
 }
コード例 #2
0
 public override List <Appointment> GetAll()
 {
     using (var context = new ClinicDbContext())
     {
         return(context.Appointments.Include(a => a.Doctor).ToList());
     }
 }
コード例 #3
0
ファイル: Repository.cs プロジェクト: mihaistancu/Clinic
 public void Add(T item)
 {
     using (var context = new ClinicDbContext())
     {
         context.Set <T>().Add(item);
         context.SaveChanges();
     }
 }
コード例 #4
0
 public override List <OfficeHours> GetAll()
 {
     using (var context = new ClinicDbContext())
     {
         return(context.OfficeHours
                .Include(o => o.Doctor)
                .Include(o => o.Office)
                .ToList());
     }
 }
コード例 #5
0
 public override List <Examination> GetAll()
 {
     using (var context = new ClinicDbContext())
     {
         return(context.Examinations
                .Include(a => a.Doctor)
                .Include(a => a.Office)
                .Include(a => a.Patient)
                .ToList());
     }
 }
コード例 #6
0
 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();
     }
 }
コード例 #7
0
ファイル: Repository.cs プロジェクト: mihaistancu/Clinic
        public virtual List <T> Search(params Expression <Func <T, bool> >[] predicates)
        {
            using (var context = new ClinicDbContext())
            {
                IQueryable <T> results = context.Set <T>();

                foreach (var predicate in predicates)
                {
                    results = results.Where(predicate);
                }

                return(results.ToList());
            }
        }
コード例 #8
0
        public override List <Appointment> Search(params Expression <Func <Appointment, bool> >[] predicates)
        {
            using (var context = new ClinicDbContext())
            {
                IQueryable <Appointment> results = context.Appointments
                                                   .Include(o => o.Doctor);

                foreach (var predicate in predicates)
                {
                    results = results.Where(predicate);
                }

                return(results.ToList());
            }
        }
コード例 #9
0
        public override List <OfficeHours> Search(params Expression <Func <OfficeHours, bool> >[] predicates)
        {
            using (var context = new ClinicDbContext())
            {
                IQueryable <OfficeHours> results = context.OfficeHours
                                                   .Include(o => o.Doctor)
                                                   .Include(o => o.Office);

                foreach (var predicate in predicates)
                {
                    results = results.Where(predicate);
                }

                return(results.ToList());
            }
        }
コード例 #10
0
        public override List <Examination> Search(params Expression <Func <Examination, bool> >[] predicates)
        {
            using (var context = new ClinicDbContext())
            {
                IQueryable <Examination> results = context.Examinations
                                                   .Include(a => a.Doctor)
                                                   .Include(a => a.Office)
                                                   .Include(a => a.Patient);

                foreach (var predicate in predicates)
                {
                    results = results.Where(predicate);
                }

                return(results.ToList());
            }
        }
コード例 #11
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();
     }
 }
コード例 #12
0
 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();
     }
 }