public UserModel CheckUser(string userName, string password, out bool status, out string errorMessage) { UserModel user = new UserModel(); status = false; DALogin daLogin = new DALogin(); DataTable dataTable = daLogin.CheckUsers(userName); errorMessage = ""; if (dataTable.Rows.Count == 0) { status = false; errorMessage = "Utilizator inexistent"; } else { for (int i = 0; i < dataTable.Rows.Count; i++) { if (password == Base64Decode(dataTable.Rows[i]["UserPassword"].ToString())) { user.UserId = Convert.ToInt32(dataTable.Rows[i]["UserId"]); user.UserName = Convert.ToString(dataTable.Rows[i]["UserName"]); user.UserPassword = Convert.ToString(dataTable.Rows[i]["UserPassword"]); user.LastLogin = DateTime.Now; status = true; errorMessage = "Logare reusita!"; daLogin.UpdateLastLogin(userName); } else { errorMessage = "Parola incorecta!"; } } } return(user); }