So my question is: Does my BLL validate my log-in, or do i put the validation on the form UI? Piece of code from my UI down below.
If so validated in the BLL layer, how do i do so?
private void ValidateForm(string username, string password)
{
var countdb = BLL.UsersBLL.VerifyDataBase();
if (countdb >= 1)
{
var userdata = BLL.UsersBLL.VerifyUserData(username, password);
if (userdata == 1)
{
Entity.UsersEntity.UserSession.username = username;
var mainwindow = Application.Current.MainWindow as MainWindow;
main main = new main();
mainwindow.Close();
main.Show();
main.username.Content = Entity.UsersEntity.UserSession.username;
}
else if (userdata <= 0)
{
ErrorHandle.Content = "Verifique o usuário ou a senha.";
}
}
else
{
MessageBox.Show("O seu banco de dados está vazio! Por favor registrar um usuário.");
register register = new register();
register.ShowDialog();
}
}
Move not UI related logic into dedicated business logic type
Then in UI code you just call it and make next decision based on the result