public string ValidateUser(string userName, string passWord) { string returnString = IdProConstants.SUCCESS; userName = userName.ToUpper().Trim(); passWord = passWord.Trim(); UserDAO userDao = new UserDAO(); User user = userDao.getUserByUserName(userName); string hash = getHashPassword(passWord); if (user == null) { returnString = "User Can not be found in the system"; } else if (!user.Password.Trim().Equals(getHashPassword(passWord))) { returnString = "Invalid Password"; } return returnString; }
public User getUserbyUserName(string userName) { UserDAO userDao = new UserDAO(); return userDao.getUserByUserName(userName); }
public bool isUserNameExist(string userName) { UserDAO userDao = new UserDAO(); return userDao.getUserByUserName(userName.Trim().ToUpper()) != null; }
public Employee getEmployeeByUserName(string userName) { ConnectionDao ConnectionDao = new ConnectionDao(); Employee employee = new Employee(); SqlCommand cmd = null; SqlConnection conn = null; SqlDataReader rs = null; string query = "select * from employees where userName=@userName"; try { conn = ConnectionDao.getConnection(); cmd = ConnectionDao.getSqlCommandWithoutTransaction(query, conn); SqlParameter param1 = new SqlParameter(); param1.ParameterName = "@userName"; param1.Value = userName; cmd.Parameters.Add(param1); rs = cmd.ExecuteReader(); if (rs.Read()) { employee.FirstName=(rs["first_name"].ToString().Trim()); employee.LastName=(rs["last_name"].ToString().Trim()); employee.Email=(rs["email"].ToString().Trim()); employee.EmployeeStatus=(rs["status"].ToString().Trim()); employee.EmployeeId = (rs["Employee_Id"].ToString().Trim()); employee.department = (rs["department"].ToString().Trim()); UserDAO userDao = new UserDAO(); User user = userDao.getUserByUserName(userName); employee.USER=user; } else { employee = null; } } catch (Exception exception) { System.Diagnostics.Trace.WriteLine("[EmployeeDAO:getEmployeeByUserName] Exception " + exception.StackTrace); employee = null; } finally { ConnectionDao.closeConnection(conn); ConnectionDao.closeDabaseEntities(cmd, rs); } return employee; }