Skip to content

Instantly share code, notes, and snippets.

@blachniet
Created December 25, 2013 12:40
Show Gist options
  • Select an option

  • Save blachniet/8122919 to your computer and use it in GitHub Desktop.

Select an option

Save blachniet/8122919 to your computer and use it in GitHub Desktop.
public Task CreateAsync(ApplicationUser user)
{
if (user == null)
{
throw new ArgumentNullException("user cannot be null.");
}
if (string.IsNullOrEmpty(user.UserName))
{
throw new ArgumentNullException("username cannot be null or empty.");
}
if (string.IsNullOrEmpty(user.Email))
{
throw new ArgumentNullException("email cannot be null or empty.");
}
//compile errors like username or email already taken...
var errors = GetErrors(user);
if (errors.Any())
{
return Task.FromResult<identityresult>(IdentityResult.Failed(errors.ToArray()));
}
userBusiness.AddUser(user.ToUser());
return Task.FromResult<identityresult>(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment