Created
August 22, 2019 18:57
-
-
Save explorer14/71f7c4b716754bd01954b43bc4f7b0e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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