implement freelancer alias creation
This commit is contained in:
@ -296,7 +296,7 @@ namespace Database {
|
||||
|
||||
/*
|
||||
* Executes the prepared statement SELECT_FREELANCER_ID
|
||||
* Takes an open pqxx::connection and the id to select by
|
||||
* Takes an open pqxx::connection and the email to select by
|
||||
*/
|
||||
pqxx::result executePreparedStatement_SELECT_FREELANCER_ID(pqxx::connection &connection, const std::string& freelancerEmail) {
|
||||
pqxx::work work(connection);
|
||||
@ -305,6 +305,17 @@ namespace Database {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes the prepared statement SELECT_FREELANCER_NAME
|
||||
* Takes an open pqxx::connection and the email to select by
|
||||
*/
|
||||
pqxx::result executePreparedStatement_SELECT_FREELANCER_NAME(pqxx::connection &connection, const std::string& freelancerEmail) {
|
||||
pqxx::work work(connection);
|
||||
pqxx::result result = work.exec_prepared(PREPARED_STATEMENT_SELECT_FREELANCER_NAME, freelancerEmail);
|
||||
work.commit();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes the prepared statement SELECT_CHECK_EMAIL_EXISTS
|
||||
* Takes an open pqxx::connection and the emailAddress to check
|
||||
@ -452,6 +463,33 @@ namespace Database {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes the prepared statement INSERT_FREELANCER_ALIAS
|
||||
* Takes an open pqxx::connection and aliasname, freelanceremail, route, routeparameter, routevalue
|
||||
* returns errorLevel
|
||||
* 0 = no error
|
||||
* 1 = query error
|
||||
* 2 = critical error
|
||||
*/
|
||||
int executePreparedStatement_INSERT_FREELANCER_ALIAS(pqxx::connection &connection, const std::string& aliasname, const std::string& freelanceremail, const std::string& route, const std::string& routeparameter, const std::string& routevalue) {
|
||||
try {
|
||||
pqxx::work work(connection);
|
||||
work.exec_prepared(PREPARED_STATEMENT_INSERT_FREELANCER_ALIAS, aliasname, freelanceremail, route, routeparameter, routevalue);
|
||||
work.commit();
|
||||
}
|
||||
catch (pqxx::sql_error const &e) {
|
||||
std::cerr
|
||||
<< "Database error: " << e.what() << std::endl
|
||||
<< "Query was: " << e.query() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
catch (std::exception const &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes the prepared statement SELECT_FREELANCER_ALIAS
|
||||
* Takes an open pqxx::connection and the freelancer email to select by
|
||||
@ -474,6 +512,19 @@ namespace Database {
|
||||
work.commit();
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes the prepared statement SELECT_CHECK_FREELANCER_ALIAS
|
||||
* Takes an open pqxx::connection and the alias name
|
||||
* Delivers true if the alias is already used
|
||||
*/
|
||||
bool executePreparedStatement_SELECT_CHECK_FREELANCER_ALIAS(pqxx::connection &connection, const std::string& aliasName) {
|
||||
pqxx::work work(connection);
|
||||
pqxx::result result = work.exec_prepared(PREPARED_STATEMENT_SELECT_CHECK_FREELANCER_ALIAS, aliasName);
|
||||
work.commit();
|
||||
std::string extractedResult = result.at(0).at(0).c_str();
|
||||
return extractedResult == "t";
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes the prepared statement UPDATE_LOGIN_VALIDATION_KEY
|
||||
* Takes an open pqxx::connection, the freelancerID and the loginKey to update the entry
|
||||
|
Reference in New Issue
Block a user