public async Task <IActionResult> Get(long appointmentId) { var query = new GetAppointmentByIdQuery(appointmentId); var result = await mediator.Send(query); return(Ok(result)); }
public async Task AppointmentHandler_Get_GetAllByIdAsync() { //Arrange var getId = 0; Appointment result = new Appointment(); GetAppointmentByIdDto resultDto = new GetAppointmentByIdDto(); var command = new GetAppointmentByIdQuery(getId); var mockAppointmentRepository = new Mock<AppointmentRepository>(null); //Act mockAppointmentRepository.Setup(x => x.GetByIdAsync(getId, It.IsAny<CancellationToken>())).ReturnsAsync(result); var sut = new GetAppointmentByIdQueryHandler(mockAppointmentRepository.Object, null); resultDto = await sut.Handle(command, CancellationToken.None); //Act Assert.NotNull(result); Assert.Equal(resultDto.Appointment.Id, getId); mockAppointmentRepository.Verify(x => x.GetByIdAsync(getId, It.IsAny<CancellationToken>()), Times.Once); mockAppointmentRepository.VerifyNoOtherCalls(); }
public async Task <ActionResult> GetAppointment([FromQuery] GetAppointmentByIdQuery query) { var result = await Mediator.Send(query); return((result != null) ? (ActionResult)Ok(result) : NotFound()); }
async Task <List <AppointmentHasTechnicianDTO> > IRequestHandler <GetAppointmentByIdQuery, List <AppointmentHasTechnicianDTO> > .Handle(GetAppointmentByIdQuery request, CancellationToken cancellationToken) { List <Domain.Model.Soporte.AppointmentHasTechnician> appointmentHasTechnician = await _appointmentRepository.GetAppointmentById(request.Id); List <AppointmentHasTechnicianDTO> appointmentDTOs = new List <AppointmentHasTechnicianDTO>(); foreach (var item in appointmentHasTechnician) { appointmentDTOs.Add( new AppointmentHasTechnicianDTO( item.AppoinmtentHasTechnicianId, item.Appointment, item.Technician ) ); } return(appointmentDTOs); }