Hello,
To check if user exist the best approach is make a query to check if user extis:
You need to add 2 conditions:
1. User.username = Username (to check if username already exists)
2. User.id <> UserId (to check if is a different record, because if you are editing the ID will be the same)
After call the entity check if is empty: If is not empty is beacuse exists a record with the same username on DB and you need to exit the flow and show a error.
Hope this can help you.
BR,
Luis