public async Task <UserServiceResponse> RegisterUserAsync(UserRegistration user) { var response = new UserServiceResponse(); var existingUser = await this._accountRepository.FindUserByEmailAsync(emailAddress : user.EmailAddress).ConfigureAwait(continueOnCapturedContext: false); if (existingUser != null) { return(response); } var result = await this._accountRepository.CreateUserAsync(user : user) .ConfigureAwait(continueOnCapturedContext: true); if (!result.Succeeded) { return(response); } response.IsValidUser = true; existingUser = await this._accountRepository.FindUserByEmailAsync(emailAddress : user.EmailAddress) .ConfigureAwait(continueOnCapturedContext: false); var emailMessage = EmailComposer.ComposeEmail(existingUser.UserName, existingUser.VerificationCode); EmailSender.SendEmail(@"*****@*****.**", existingUser.Email, @"testuser44", emailMessage); return(response); }