Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created October 26, 2023 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/70bf2f2c7c7cac39e9d7e4ae8f6a529f to your computer and use it in GitHub Desktop.
Save dcomartin/70bf2f2c7c7cac39e9d7e4ae8f6a529f to your computer and use it in GitHub Desktop.
public class GetOrderQueryHandler : IRequestHandler<GetOrderQuery, OrderResponse>
{
private readonly IOrderReadService _orderReadService;
public GetOrderQueryHandler(IOrderReadService orderReadService)
{
_orderReadService = orderReadService;
}
public async Task<OrderResponse> Handle(GetOrderQuery request, CancellationToken cancellationToken)
{
var orderResponse = await _orderReadService.GetOrderByIdAsync(request.OrderId);
if (orderResponse is null)
{
throw new OrderNotFoundException(request.OrderId);
}
return orderResponse;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment