示例#1
0
        public override async Task <ActionResult <GetByIdAppointmentResponse> > HandleAsync([FromRoute] GetByIdAppointmentRequest request, CancellationToken cancellationToken)
        {
            var response = new GetByIdAppointmentResponse(request.CorrelationId());

            var spec     = new ScheduleByIdWithAppointmentsSpec(request.ScheduleId); // TODO: Just get that day's appointments
            var schedule = await _scheduleRepository.GetBySpecAsync(spec);

            var appointment = schedule.Appointments.FirstOrDefault(a => a.Id == request.AppointmentId);

            if (appointment == null)
            {
                return(NotFound());
            }

            response.Appointment = _mapper.Map <AppointmentDto>(appointment);

            // load names
            var clientSpec = new ClientByIdIncludePatientsSpecification(appointment.ClientId);
            var client     = await _clientRepository.GetBySpecAsync(clientSpec);

            var patient = client.Patients.First(p => p.Id == appointment.PatientId);

            response.Appointment.ClientName  = client.FullName;
            response.Appointment.PatientName = patient.Name;

            return(Ok(response));
        }
        public override async Task <ActionResult <GetByIdAppointmentResponse> > HandleAsync([FromRoute] GetByIdAppointmentRequest request, CancellationToken cancellationToken)
        {
            var response = new GetByIdAppointmentResponse(request.CorrelationId());

            var appointment = await _repository.GetByIdAsync <Appointment, Guid>(request.AppointmentId);

            if (appointment is null)
            {
                return(NotFound());
            }

            response.Appointment = _mapper.Map <AppointmentDto>(appointment);

            return(Ok(response));
        }