/// <summary> /// Loads all places for currently logged in traienr /// </summary> /// <returns></returns> public List <PlaceModel> loadPlacesFromDataBase() { List <PlaceModel> placesList = new List <PlaceModel>(); try { using (OracleConnection connection = new OracleConnection(OracleSQLConnector.GetConnectionString())) { connection.Open(); OracleCommand cmd; string sql = String.Format("select * from place_table WHERE trainer_table_id = {0}", GlobalClass.getTrainerID()); cmd = new OracleCommand(sql, connection); cmd.CommandType = CommandType.Text; OracleDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { PlaceModel place = new PlaceModel(); place.setID(reader.GetInt32(0)); place.setCity(reader.GetString(1)); place.setPostCode(reader.GetString(2)); place.setStreet(reader.GetString(3)); place.setDescription(reader.GetString(4)); placesList.Add(place); } } finally { reader.Close(); } } }catch { } return(placesList); }
public PlaceModel loadPlaceFromDataBase(int placeID) { PlaceModel place = new PlaceModel(); try { using (OracleConnection connection = new OracleConnection(OracleSQLConnector.GetConnectionString())) { connection.Open(); OracleCommand cmd; string sql = String.Format("select * from place_table WHERE id = {0}", placeID); cmd = new OracleCommand(sql, connection); cmd.CommandType = CommandType.Text; OracleDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { place.setID(reader.GetInt32(0)); place.setCity(reader.GetString(1)); place.setPostCode(reader.GetString(2)); place.setStreet(reader.GetString(3)); place.setDescription(reader.GetString(4)); } } finally { reader.Close(); } } }catch { } return(place); }