good morning everybody! I Have in my application a User class with a CPF property (In my country is equivalent to SSN - Social Security Number in USA), then I have my Identity already implemented and working. My question is, how do I find if already exists a CPF in db with UserManager? Can I Use UserManager or should I use my DbContext?
I need to check if exists the same number that the user is sending on the API request, I've already set that the property index has to be unique.
public async Task<IdentityResult> RegisterUser(AddUserDto addUserDto)
{
var user = _mapper.Map<User>(addUserDto);
var result = await _userManager.CreateAsync(user, addUserDto.Password);
if (addUserDto.Roles != null && result.Succeeded)
await _userManager.AddToRolesAsync(user, addUserDto.Roles);
return result;
}
Before the _userManager.CreateAsync(); I need to do the checking.