Actaully from your code sample i do not understand where the problem is. But i write some way how to code for authenticating user. If you do so and unit test then easily you understand where the problem is.
step 1> You should write a IsUserExists methold to your business layer as follows
public class UserBusinessService
{
private IUserDataService _userDataService = new UserDataService();
public bool IsUserExists(string userName, string password)
{
User user = _userDataService.GetUser(userName, password);
return user != null;
}
}
After implementing that type of code, you should unit test your code so that you can understand any problem there or not.
From your WindowsForm/WPF UI class you should call it and verify user properly
public class LoginForm:WindowsFormBase
{
private readonly IUserBusinessService _userService= new UserBusinessService();
public void Login_Click(object sender, EventArgs e)
{
bool success = _userService.IsUserExists(txtUserName.Text, txtPassword.Text);
if(!success)
{
MessageBox.Show("User name/password is incorrect. Please check");
}
else
{
}
}
}