Skip to content

Instantly share code, notes, and snippets.

@taylonr
Created January 19, 2013 03:26
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 taylonr/4570586 to your computer and use it in GitHub Desktop.
Save taylonr/4570586 to your computer and use it in GitHub Desktop.
public void Create(User user)
{
if(string.IsNullOrWhiteSpace(user.Email))
throw new InvalidEmailException();
if(!new Regex("^[A-Za-z]\w{6,}[A-Za-z]$").IsMatch(user.Password))
throw new InvalidPasswordException();
if(string.IsNullOrWhiteSpace(user.FirstName) || string.IsNullOrWhiteSpace(user.LastName))
throw new InvalidNameException();
var repo = new UserRepository();
repo.Create(new UserEntity{
Email = user.Email;
Password = user.Password;
FirstName = user.FirstName;
LastName = user.LastName;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment