public async Task <IActionResult> Get(long appointmentId)
        {
            var query  = new GetAppointmentByIdQuery(appointmentId);
            var result = await mediator.Send(query);

            return(Ok(result));
        }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
        public async Task <ActionResult> GetAppointment([FromQuery] GetAppointmentByIdQuery query)
        {
            var result = await Mediator.Send(query);

            return((result != null) ? (ActionResult)Ok(result) : NotFound());
        }
Exemplo n.º 4
0
        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);
        }