コード例 #1
0
        public async Task <IReadOnlyList <Appointment> > GetAllUpcomingForDoctorAsync(DoctorId doctorId,
                                                                                      CancellationToken cancellation = default)
        {
            var context = await _dbContextProvider.GetAsync();

            var now = _systemClockService.UtcNow;

            return(await context.AppointmentTables
                   .Where(x => x.AppointmentAt >= now)
                   .Where(x => x.DoctorId == doctorId.Value)
                   .Select(x => new Appointment(new AppointmentId(x.AppointmentId), new DoctorId(x.DoctorId), new PatientId(x.PatientId),
                                                x.AppointmentAt, new AppointmentDuration(x.Duration)))
                   .ToListAsync(cancellation));
        }
コード例 #2
0
        public async Task <IReadOnlyList <DoctorAvailability> > GetAllForDoctorAsync(DoctorId doctorId,
                                                                                     CancellationToken cancellationToken = default)
        {
            var context = await _dbContextProvider.GetAsync();

            return(await context.DoctorAvailabilityTables
                   .Where(x => x.DoctorId == doctorId.Value)
                   .Select(x => new DoctorAvailability(new DoctorAvailabilityId(x.DoctorAvailabilityId), new DoctorId(x.DoctorId), x.DayOfWeek,
                                                       new TimeOfDay(x.StartsAt), new TimeOfDay(x.EndsAt)))
                   .ToListAsync(cancellationToken));
        }
コード例 #3
0
        public async Task <Patient> GetByIdAsync(PatientId patientId, CancellationToken cancellation = default)
        {
            var context = await _dbContextProvider.GetAsync();

            var patientTable = await context.PatientTables.SingleOrDefaultAsync(x => x.PatientId == patientId.Value, cancellation);

            if (patientTable == null)
            {
                return(null);
            }

            return(new Patient(new PatientId(patientTable.PatientId), patientTable.Name));
        }
コード例 #4
0
        public async Task <Doctor> GetByIdAsync(DoctorId doctorId, CancellationToken cancellation = default)
        {
            var context = await _dbContextProvider.GetAsync();

            var doctorTable = await context.DoctorTables.SingleOrDefaultAsync(x => x.DoctorId == doctorId.Value, cancellation);

            if (doctorTable == null)
            {
                return(null);
            }

            return(new Doctor(new DoctorId(doctorTable.DoctorId), doctorTable.Name));
        }
コード例 #5
0
        public async Task <IQueryable <AppointmentTable> > GetAppointmentTablesAsync(CancellationToken cancellation = default)
        {
            var context = await _dbContextProvider.GetAsync();

            return(context.Set <AppointmentTable>());
        }