Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
namespace Domain.ProductInformation.EventHandlers
{
public class ProductInformationHandler :
IHandleEvents<ProductInformation>
{
private readonly ReviewUsecase _reviewUseCase;
private readonly IStorePurchaseOrders _purchaseOrderStore;
private readonly IStoreProducts _productStore;
public ProductInformationHandler(
ReviewUsecase reviewUseCase,
IStorePurchaseOrders purchaseOrderStore,
IStoreProducts productStore)
{
_reviewUseCase = reviewUseCase;
_purchaseOrderStore = purchaseOrderStore;
_productStore = productStore;
}
public async Task Handle(ProductInformation eventToHandle)
{
var product = eventToHandle.ToEntity();
await _productStore.Save();
var purchaseOrderItems = await _purchaseOrderStore
.GetFor(eventToHandle.ProductId);
foreach (var item in purchaseOrderItems)
{
await _reviewUseCase.Execute(item, product);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.