Skip to content

Instantly share code, notes, and snippets.

@explorer14
Last active June 13, 2020 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save explorer14/ba856f44bb2e39bc18018025ac6f4918 to your computer and use it in GitHub Desktop.
Save explorer14/ba856f44bb2e39bc18018025ac6f4918 to your computer and use it in GitHub Desktop.
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