+++ /customer/$freelancer/template/$templateName

Route handling the display of a Template
And minor fix enabling the root route to handle post
This commit is contained in:
Tina_Azure
2023-04-04 22:40:27 +02:00
parent de91af605e
commit 407d0aeecf
2 changed files with 29 additions and 2 deletions

View File

@ -25,7 +25,7 @@ int main() {
/*
* Freelancer Profile listing for customers
*/
CROW_ROUTE(app, "/")
CROW_ROUTE(app, "/").methods("POST"_method)
([databaseURI]() {
pqxx::connection databaseConnection(databaseURI);
pqxx::result result = Database::executeStatement_SELECT_FREELANCERS_WITHCOMMISSIONSSTATE(databaseConnection);
@ -79,6 +79,33 @@ int main() {
});
/*
* Page representing a freelancers Template
*/
CROW_ROUTE(app, "/customer/<string>/template/<string>").methods("POST"_method)
([databaseURI](const crow::request& postRequest, string freelancerName, string templateName ) {
int templateID = stoi(Utilities::extractSingleValueFromRequestBody(postRequest.body.c_str(), "templateID"));
pqxx::connection databaseConnection(databaseURI);
pqxx::result resultTemplate = Database::executePreparedStatement_SELECT_TEMPLATE(databaseConnection, templateID);
crow::json::wvalue resultJsonTemplate = Database::convertResultRowToJSON(resultTemplate);
string templateHTML = "customer_Freelancer_Template.html";
auto page = crow::mustache::load(templateHTML);
crow::mustache::context ctx(resultJsonTemplate);
return page.render(ctx);
});