public async Task <SpecialistAppointmentsDto> HandleAsync(AppointmentQuery query) { Specialist doctor = await _specialistRepo.GetAsync(query.SpecialistId); IEnumerable <Appointment> bookings = await _bookingsRepo.FindAsync(x => x.PatientId == query.SpecialistId); if (doctor is null) { throw new MedParkException("bookings_specialist_does_not_exist", $"Specialist with Id {query.SpecialistId} does not exist."); } SpecialistAppointmentsDto result = new SpecialistAppointmentsDto() { SpecialisttDetails = _mapper.Map <SpecialistDto>(doctor), BookingDetails = _mapper.Map <List <AppointmentDto> >(bookings) }; return(result); }
public async Task <CustomerAppointmentsDto> HandleAsync(AppointmentQuery query) { Customer patient = await _patientRepo.GetAsync(query.CustomerId); IEnumerable <Appointment> bookings = await _bookingsRepo.FindAsync(x => x.PatientId == query.CustomerId); if (patient is null) { throw new MedParkException("bookings_patient_does_not_exist", $"Patient with Id {query.CustomerId} does not exist."); } CustomerAppointmentsDto result = new CustomerAppointmentsDto() { PatientDetails = _mapper.Map <CustomerDto>(patient), BookingDetails = _mapper.Map <List <AppointmentDto> >(bookings) }; return(result); }
public async Task <SpecialistAppointmentTypesDTO> HandleAsync(AppointmentTypeQuery query) { var linkedAppointmentTypes = await _acceptedAppointmentTypeRepo.FindAsync(x => x.SpecialistId == query.SpecialistId); var specialist = await _specialistRepo.GetAsync(query.SpecialistId); if (specialist is null) { throw new MedParkException("specialist_does_not_Exist", $"The specialist {query.SpecialistId} does not exists."); } SpecialistAppointmentTypesDTO dto = new SpecialistAppointmentTypesDTO { SpecialistId = query.SpecialistId, SpecialistName = specialist.FirstName + " " + specialist.Surname, }; var ids = linkedAppointmentTypes.ToList().Select(x => x.Id).ToList(); IEnumerable <AppointmentType> appTypes = await _appointmentTypeRepo.FindAsync(x => ids.Contains(x.Id)); dto.TypesLinkedToSpecilaist.AddRange(_mapper.Map <List <AppointmentTypeDTO> >(appTypes)); return(dto); }
public async Task <ActionResult <IEnumerable <CustomerDto> > > GetAll() { var customers = await _customerRepo.GetAsync(x => x.Id == Guid.Parse("55319E5C-1422-4EC4-A85E-181446DF43B5")); return(Ok(_mapper.Map <CustomerDto>(customers))); }