Created
January 28, 2013 16:12
-
-
Save csainty/4656830 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 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