async Task <IActionResult> NovaConta(RegisterUserViewModel registerUser, bool authenticar = false) { /* * var user = new ApplicationUserWidoutEntity * { * UserName = registerUser.Email, * Email = registerUser.Email, * EmailConfirmed = true * }; */ var user = new ApplicationUser { UserName = registerUser.Email, Email = registerUser.Email, EmailConfirmed = true }; var result = await _userManager.CreateAsync(user, registerUser.Senha); if (result.Succeeded) { /**/ try { await _iusuarioApp.IncluirUsuario(registerUser); } catch (Exception) { await _userManager.DeleteAsync(user); throw; } if (_notificacoes.TemNotificacoes) { await _userManager.DeleteAsync(user); return(CustomResponse(registerUser)); } if (authenticar) { await _signInManager.SignInAsync(user, false); return(CustomResponse(await Util.GerarJwt(user.Email, _userManager, _appSettings))); } return(CustomResponse(registerUser)); } foreach (var error in result.Errors) { AdicionarNotificacao(error.Description); } return(CustomResponse(registerUser)); }