Commit b020fb22 authored by Almouhannad's avatar Almouhannad

(B) Change update user behavior

parent 6949ca50
...@@ -27,18 +27,26 @@ public class UpdateDoctorUserHandler : CommandHandlerBase<UpdateDoctorUserComman ...@@ -27,18 +27,26 @@ public class UpdateDoctorUserHandler : CommandHandlerBase<UpdateDoctorUserComman
#endregion #endregion
#region 2. Check unique username #region 2. Check unique username
if (user.User.UserName != request.UserName) // Unchanged user name, so just changing password
{
var uniqueUserNameResult = await _userRepository.IsUserNameAvailableAsunc(request.UserName); var uniqueUserNameResult = await _userRepository.IsUserNameAvailableAsunc(request.UserName);
if (uniqueUserNameResult.IsFailure) if (uniqueUserNameResult.IsFailure)
return Result.Failure(uniqueUserNameResult.Error); return Result.Failure(uniqueUserNameResult.Error);
if (uniqueUserNameResult.Value == false) if (uniqueUserNameResult.Value == false)
return Result.Failure(IdentityErrors.TakenUserName); return Result.Failure(IdentityErrors.TakenUserName);
}
#endregion #endregion
#region 3. change username #region 3. change username
if (user.User.UserName != request.UserName) // Unchanged user name, so just changing password
{
var updateUserNameResult = await _userRepository.ChangeUserName(user.User, request.UserName); var updateUserNameResult = await _userRepository.ChangeUserName(user.User, request.UserName);
if (updateUserNameResult.IsFailure) if (updateUserNameResult.IsFailure)
return Result.Failure(updateUserNameResult.Error); return Result.Failure(updateUserNameResult.Error);
}
#endregion #endregion
#region 4. Change password #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