You can do that in following waysCheck if duplicate
Create a method to check the username is already exists in database
public bool IsUsernameExists(string strUsername)
OrThrow the exception
Put a constraint for the
column in table. If you try to save duplicate name then it will raise the error, based on the error you can throw the appropriate message to the user.
Now you decide.