Skip to content

Instantly share code, notes, and snippets.

@explorer14

explorer14/CustomerRegUseCase.cs Secret

Last active Jun 13, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.