public List <SecurityUserRole> UserRoleList(string userid) { List <SecurityUserRole> rolelist = new List <SecurityUserRole>(); securityUserRoles = new List <SecurityUserRole>(); using (var connection = new MySqlConnection(ConnString.ConnectionStringFramework)) { var commandString = string.Format( " SELECT " + " UniqueID " + " ,FK_UserID " + " ,FK_Role " + " ,StartDate " + " ,EndDate " + " ,IsActive " + " ,IsVoid " + " FROM SecurityUserRole " + " WHERE FK_UserID = '{0}' AND IsActive='Y' ", userid); using (var command = new MySqlCommand( commandString, connection)) { connection.Open(); using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { SecurityUserRole SecurityUserRole = new SecurityUserRole(_headerInfo); SecurityUserRole.UniqueID = Convert.ToInt32(reader["UniqueID"].ToString()); SecurityUserRole.FK_UserID = reader["FK_UserID"].ToString(); SecurityUserRole.FK_Role = reader["FK_Role"].ToString(); SecurityUserRole.StartDate = Convert.ToDateTime(reader["StartDate"].ToString()); SecurityUserRole.EndDate = Convert.ToDateTime(reader["EndDate"]); SecurityUserRole.IsActive = reader["IsActive"].ToString(); SecurityUserRole.IsVoid = reader["IsVoid"].ToString(); rolelist.Add(SecurityUserRole); securityUserRoles.Add(SecurityUserRole); } } } } return(rolelist); }
/// <summary> /// List user settings for a given user /// </summary> /// <returns></returns> public ResponseStatus ListRoleForUser(string userID, List <SecurityUserRole> roleList) { using (var connection = new MySqlConnection(ConnString.ConnectionStringFramework)) { var commandString = string.Format( " SELECT " + FieldName.FK_UserID + "," + FieldName.FK_Role + " " + " FROM SecurityUserRole " + " WHERE FK_UserID = '{0}' " + " ORDER BY FK_Role ASC ", userID ); using (var command = new MySqlCommand( commandString, connection)) { try { connection.Open(); using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var userRole = new SecurityUserRole(_headerInfo); userRole.FK_UserID = reader[FieldName.FK_UserID].ToString(); userRole.FK_Role = reader[FieldName.FK_Role].ToString(); // Check if document exists // roleList.Add(userRole); } } } catch (Exception ex) { LogFile.WriteToTodaysLogFile(ex.ToString(), HeaderInfo.Instance.UserID); } } } return(new ResponseStatus()); }