add tour place editor
This commit is contained in:
@@ -34,8 +34,8 @@ namespace LibSernatur {
|
||||
* @param hora_llegada The time of arrival
|
||||
* @param fecha_salida The date of departure
|
||||
* @param hora_salida The time of departure
|
||||
* @param tour The tour taken
|
||||
* @param lugar The place visisted
|
||||
* @param tour The tour associated
|
||||
* @param lugar The place associated
|
||||
*/
|
||||
public Asociado (string fecha_llegada = "", string hora_llegada = "", string fecha_salida = "", string hora_salida = "", Tour? tour = null, Lugar? lugar = null) {
|
||||
this.fecha_llegada = fecha_llegada;
|
||||
@@ -175,6 +175,51 @@ namespace LibSernatur {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert an association in the database
|
||||
* @param conn The database connection
|
||||
* @param asociado The association to insert
|
||||
* @throws PostgresError Thrown if there is a problem with escaping strings
|
||||
* @throws DBError Thrown if an invalid value is passed
|
||||
*/
|
||||
public static void insert_asociado (Connection conn, Asociado asociado) throws PostgresError, DBError {
|
||||
if (asociado.tour.id_tour == 0 || asociado.lugar.id_lugar == 0) {
|
||||
throw new DBError.INVALID_VALUE (_ ("The id of the tour or the place is invalid!"));
|
||||
}
|
||||
var res = conn.db.exec (Query.get_query (conn, Query.Type.INSERT_ASSOCIATED, asociado));
|
||||
if (res.get_status () != ExecStatus.COMMAND_OK) {
|
||||
#if DEBUG
|
||||
error (conn.db.get_error_message ());
|
||||
#else
|
||||
warning (conn.db.get_error_message ());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an association in the database
|
||||
* @param conn The database connection
|
||||
* @param asociado The association to delete
|
||||
* @throws PostgresError Thrown if there is a problem with escaping strings
|
||||
* @throws DBError Thrown if an invalid value is passed
|
||||
*/
|
||||
public static void delete_associated (Connection conn, Asociado asociado) throws PostgresError, DBError {
|
||||
if (asociado.tour.id_tour == 0 || asociado.lugar.id_lugar == 0) {
|
||||
throw new DBError.INVALID_VALUE (_ ("The id of the tour or place is invalid!"));
|
||||
}
|
||||
var res = conn.db.exec (Query.get_query (conn, Query.Type.DELETE_TOUR, asociado));
|
||||
if (res.get_status () != ExecStatus.COMMAND_OK) {
|
||||
if (res.get_error_field (FieldCode.SQLSTATE) == "23503") {
|
||||
throw new DBError.FOREIGN_KEY_CONSTAINT (res.get_error_field (FieldCode.MESSAGE_PRIMARY));
|
||||
}
|
||||
#if DEBUG
|
||||
error (conn.db.get_error_message ());
|
||||
#else
|
||||
warning (conn.db.get_error_message ());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace LibSernatur {
|
||||
/**
|
||||
* Delete a tour in the database
|
||||
* @param conn The database connection
|
||||
* @param tour The tour to update
|
||||
* @param tour The tour to delete
|
||||
* @throws PostgresError Thrown if there is a problem with escaping strings
|
||||
* @throws DBError Thrown if an invalid value is passed
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user