public List<aptitude> GetCharacterAptitudes(uint id_character) { var query = @"select id_aptitude, name, description, class from dnd.aptitude where id_aptitude in (select aptitude from dnd.character_has_aptitude where character_has_aptitude.`character` = " + id_character + ");"; List<aptitude> list_aptitudes = new List<aptitude>(); if (OpenConnection()) { using (MySqlCommand cmd = new MySqlCommand(query, connection)) { MySqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { aptitude a = new aptitude() { uid = dataReader.GetUInt32(0), name = dataReader.IsDBNull(1) ? null : dataReader.GetString(1), description = dataReader.IsDBNull(2) ? null : dataReader.GetString(2), classe = new complete_class() { uid = dataReader.GetUInt32(3)} }; list_aptitudes.Add(a); } } dataReader.Close(); } this.CloseConnection(); foreach(var a in list_aptitudes) { if(a.classe.uid > 0) a.classe = GetClass(a.classe.uid); } } return list_aptitudes; }
public aptitude GetAptitude(uint id_aptitude) { var query = "select name, description, class from dnd.aptitude where id_aptitude = " + id_aptitude + ";"; var new_aptitude = new aptitude(); uint id_class = 0; if (OpenConnection()) { using (MySqlCommand cmd = new MySqlCommand(query, connection)) { MySqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { new_aptitude = new aptitude() { uid = id_aptitude, name = dataReader.IsDBNull(0) ? null : dataReader.GetString(0), description = dataReader.IsDBNull(1) ? null : dataReader.GetString(1) }; id_class = dataReader.GetUInt32(2); } } dataReader.Close(); } this.CloseConnection(); if (id_class > 0) new_aptitude.classe = GetClass(id_class); } return new_aptitude; }