public async Task <ApplicationUserResponse> UpdateAsync([FromBody] ApplicationUserAddRequest request) { if (request.password != null && !await _userValidators.ValidatePasswordAsync(request.user, request.password)) { return(GetResponse(false, _userValidators.InvalidPasswordMessage)); } var user = await _applicationUsersRepository.GetByIdAsync(request.user.Id); if (user.UserName != request.user.UserName && !await _userValidators.ValidateUserName(request.user.UserName)) { return(GetResponse(false, _userValidators.InvalidUserNameMessage)); } var result = await _applicationUsersRepository.UpdateAsync(request.user); if (!result) { return(GetResponse(false)); } if (request.password != null) { var passwordChangeResult = await _applicationUsersRepository.ChangePassword(user, request.password); if (!passwordChangeResult) { return(GetResponse(false)); } } return(GetResponse(true)); }
public async Task <ApplicationUserResponse> AddAsync([FromBody] ApplicationUserAddRequest request) { if (!await _userValidators.ValidatePasswordAsync(request.user, request.password)) { return(GetResponse(false, _userValidators.InvalidPasswordMessage)); } if (!await _userValidators.ValidateUserName(request.user.UserName)) { return(GetResponse(false, _userValidators.InvalidUserNameMessage)); } var result = await _applicationUsersRepository.AddTenantManagerAsync(request.user, request.password); return(GetResponse(result)); }