Commit b020fb22 authored by Almouhannad's avatar Almouhannad

(B) Change update user behavior

parent 6949ca50
......@@ -27,18 +27,26 @@ public class UpdateDoctorUserHandler : CommandHandlerBase<UpdateDoctorUserComman
#endregion
#region 2. Check unique username
var uniqueUserNameResult = await _userRepository.IsUserNameAvailableAsunc(request.UserName);
if (uniqueUserNameResult.IsFailure)
return Result.Failure(uniqueUserNameResult.Error);
if (uniqueUserNameResult.Value == false)
return Result.Failure(IdentityErrors.TakenUserName);
if (user.User.UserName != request.UserName) // Unchanged user name, so just changing password
{
var uniqueUserNameResult = await _userRepository.IsUserNameAvailableAsunc(request.UserName);
if (uniqueUserNameResult.IsFailure)
return Result.Failure(uniqueUserNameResult.Error);
if (uniqueUserNameResult.Value == false)
return Result.Failure(IdentityErrors.TakenUserName);
}
#endregion
#region 3. change username
var updateUserNameResult = await _userRepository.ChangeUserName(user.User, request.UserName);
if (updateUserNameResult.IsFailure)
return Result.Failure(updateUserNameResult.Error);
if (user.User.UserName != request.UserName) // Unchanged user name, so just changing password
{
var updateUserNameResult = await _userRepository.ChangeUserName(user.User, request.UserName);
if (updateUserNameResult.IsFailure)
return Result.Failure(updateUserNameResult.Error);
}
#endregion
#region 4. Change password
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment