Last active
January 6, 2018 13:44
-
-
Save rmaziarka/d3b0d39a3c1c1804641e19a0cff742ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class ProductAddedEventHandler: INotificationHandler<ProductAddedEvent> | |
{ | |
private readonly IProductReadModelRepository _repo; | |
public ProductAddedEventHandler(IProductReadModelRepository repo) | |
{ | |
_repo = repo; | |
} | |
public void Handle(ProductAddedEvent @event) | |
{ | |
var product = new ProductReadModel(@event); | |
_repo.Insert(product); | |
} | |
} | |
public class ReviewAddedEventHandler : INotificationHandler<ReviewAddedEvent> | |
{ | |
private readonly IProductReadModelRepository _repo; | |
public ReviewAddedEventHandler(IProductReadModelRepository repo) | |
{ | |
_repo = repo; | |
} | |
public void Handle(ReviewAddedEvent @event) | |
{ | |
var product = _repo.Find(@event.ProductId); | |
product.Apply(@event); | |
_repo.Update(product); | |
} | |
} | |
public class OrderCompletedEventHandler : INotificationHandler<OrderCompletedEvent> | |
{ | |
private readonly IProductReadModelRepository _repo; | |
public OrderCompletedEventHandler(IProductReadModelRepository repo) | |
{ | |
_repo = repo; | |
} | |
public void Handle(OrderCompletedEvent @event) | |
{ | |
var product = _repo.Find(@event.ProductId); | |
product.Apply(@event); | |
_repo.Update(product); | |
} | |
} | |
public class FieldValueChangedEventHandler : INotificationHandler<FieldValueChangedEvent> | |
{ | |
private readonly IProductReadModelRepository _repo; | |
public FieldValueChangedEventHandler(IProductReadModelRepository repo) | |
{ | |
_repo = repo; | |
} | |
public void Handle(FieldValueChangedEvent @event) | |
{ | |
var product = _repo.Find(@event.ProductId); | |
product.Apply(@event); | |
_repo.Update(product); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment