public async Task <ICommandResult <Car> > Handle(GetCarCommand command, CancellationToken cancellationToken) { int carId = command.Id; Car car = await _carRepository.GetAsync(carId, cancellationToken); if (car == null) { return(new CommandResult <Car>(CommandStatus.NotFound, null)); } return(new CommandResult <Car>(CommandStatus.Ok, car)); }
public Task <IActionResult> GetAsync( [FromServices] GetCarCommand command, int carId, CancellationToken cancellationToken) => command.ExecuteAsync(carId, cancellationToken);