Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created May 26, 2021 21:52
Show Gist options
  • Save dcomartin/6261f18b31b2494ab241101eea584f56 to your computer and use it in GitHub Desktop.
Save dcomartin/6261f18b31b2494ab241101eea584f56 to your computer and use it in GitHub Desktop.
public class GetProductBySkuHandlerDelegateExample : IRequestHandler<GetProductBySkuRequest, ProductViewModel>
{
private readonly ProductDelegates.GetProductBySku _getProduct;
public GetProductBySkuHandlerDelegateExample(ProductDelegates.GetProductBySku getProduct)
{
_getProduct = getProduct;
}
public async Task<ProductViewModel> Handle(GetProductBySkuRequest request, CancellationToken cancellationToken)
{
var product = await _getProduct(request.Sku);
return product.ToViewModel();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment