Created
February 23, 2020 12:13
-
-
Save pereiren/9673c9c214bac3ee38b4b9ee7987f576 to your computer and use it in GitHub Desktop.
Domain Service
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
public class CheckoutService : IDomainService | |
{ | |
IRepository<Purchase> purchaseRepository; | |
public CheckoutService(IRepository<Purchase> purchaseRepository) | |
{ | |
this.purchaseRepository = purchaseRepository; | |
} | |
public Purchase Checkout(Customer customer, Cart cart) | |
{ | |
Purchase purchase = Purchase.Create(cart); | |
this.purchaseRepository.Add(purchase); | |
cart.Clear(); | |
DomainEvents.Raise<CustomerCheckedOut>(new CustomerCheckedOut() { Purchase = purchase }); | |
return purchase; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment