Пример #1
0
        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));
        }
Пример #2
0
 public Task <IActionResult> GetAsync(
     [FromServices] GetCarCommand command,
     int carId,
     CancellationToken cancellationToken) => command.ExecuteAsync(carId, cancellationToken);