Skip to content

Instantly share code, notes, and snippets.

@dcomartin

dcomartin/UseDelegate.cs Secret

Created May 26, 2021
Embed
What would you like to do?
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