-
-
Save explorer14/ba856f44bb2e39bc18018025ac6f4918 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
public class CustomerRegistrationUseCase | |
{ | |
public async Task RegisterCustomer( | |
CustomerRegistrationRequest customerRegistrationRequest) | |
{ | |
var customer = await registeredCustomers.GetByEmail( | |
customerRegistrationRequest.Email); | |
if (customer == null) | |
{ | |
var newCustomer = customerRegistrationRequest.ToNewCustomer(); | |
await registeredCustomers.Add(newCustomer); | |
await eventBus.Publish( | |
new NewCustomerRegistered(newCustomer))); | |
} | |
else | |
{ | |
throw new CustomerAlreadyExists(customer); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment