I'm trying to add a user in my database but when I create it it is not added and it doesn't give me an error message. When I add a breakpoint to the CeateUser method the code is running but when I add a breakpoint on the result condition, the code is never reached.
Here's my PageModel
public class AddUserModel : PageModel
{
[BindProperty]
public NewAccountInput AccountInput { get; set; }
private UserManager<AdminUser> UserManager { get; set; }
public AddUserModel(UserManager<AdminUser> userManager)
{
UserManager = userManager;
}
public void OnPost()
{
if(AccountInput.ComfirmationPassword != AccountInput.Password)
{
return;
}
_ = CreateUser();
}
public async Task<bool> CreateUser()
{
var result = await UserManager.CreateAsync(new AdminUser()
{
Email = AccountInput.Email,
FirstName = AccountInput.UserName,
LastName = AccountInput.UserName,
UserName = AccountInput.Email
}, AccountInput.Password);
if (result.Succeeded)
{
return true;
}
else
{
return false;
}
}
}