diff --git a/src/main.cpp b/src/main.cpp index 328b4c6..40dda2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ #include #include #include "database.cpp" +#include "utilities.cpp" using namespace std; @@ -39,18 +40,20 @@ int main() { /* * Freelancer Profile Page for customers */ - CROW_ROUTE(app, "/customer//") - ([databaseURI](string freelancerName, int freelancerID) { + CROW_ROUTE(app, "/customer/").methods("POST"_method) + ([databaseURI](const crow::request& postRequest, string freelancerName ) { + //Parses the request body and extracts the specified value + int freelancerID = stoi(Utilities::extractSingleValueFromRequestBody(postRequest.body.c_str(), "freelancerID")); + pqxx::connection databaseConnection(databaseURI); pqxx::result resultFreelancer = Database::executePreparedStatement_SELECT_FREELANCER(databaseConnection, freelancerID); + //error handling if invalid ID was delivered string freelancerHTML = "customer_FreelancerListing_NOTFOUND.html"; - //crow::json::wvalue resultJsonFreelancer; - crow::json::wvalue resultJsonFreelancerTemplate; + crow::json::wvalue resultJsonFreelancerTemplate; if (resultFreelancer.size() != 0){ freelancerHTML = "customer_FreelancerListing.html"; - //resultJsonFreelancer = Database::convertResultRowToJSON(resultFreelancer); pqxx::result resultFreelancerTemplates = Database::executePreparedStatement_SELECT_FREELANCER_TEMPLATES(databaseConnection, freelancerID); resultJsonFreelancerTemplate = Database::convertResultToJSON(resultFreelancerTemplates, "templates"); }