Skip to content

Instantly share code, notes, and snippets.

@csainty
Created January 28, 2013 16:12
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 csainty/4656830 to your computer and use it in GitHub Desktop.
Save csainty/4656830 to your computer and use it in GitHub Desktop.
public interface IsEmailAlreadyInUse
{
Task<bool> Execute(string emailAddress);
}
public interface CreateUser
{
Task Execute(string username, string email);
}
internal class SqlRepository : IsEmailAlreadyInUse
{
Task<bool> IsEmailAlreadyInUse.Execute(string emailAddress)
{
// Implementation goes here
}
Task CreateUser.Execute(string username, string emailAddress)
{
// Implementation goes here
}
}
public class CreateUserCommand
{
private readonly IsEmailAlreadyInUse isEmailAlreadyInUse;
private readonly CreateUser createUser;
// ctor
public async Task<bool> Execute(string username, string emailAddress)
{
if (await this.isEmailAlreadyInUse(emailAddress)) return false;
await this.createUser(username, emailAddress);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment