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