Handler for the fulfilment of a request WIP
This commit is contained in:
70
src/main.cpp
70
src/main.cpp
@ -1,9 +1,10 @@
|
||||
#include "crow.h"
|
||||
#include <pqxx/pqxx>
|
||||
#include <string>
|
||||
#include <fmt/core.h>
|
||||
#include "database.cpp"
|
||||
#include "utilities.cpp"
|
||||
#include <pqxx/pqxx>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fmt/core.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -148,6 +149,69 @@ int main() {
|
||||
|
||||
|
||||
|
||||
CROW_ROUTE(app, "/customer/<string>/template/<string>/request/fulfilment").methods("POST"_method)
|
||||
([databaseURI, configuration](const crow::request& postRequest, string freelancerName, string templateName ) {
|
||||
|
||||
Database::requestsItem newRequest;
|
||||
|
||||
|
||||
|
||||
|
||||
string postRequestBody = postRequest.body.c_str();
|
||||
Utilities::decodeString(postRequestBody);
|
||||
vector<string> splitPostRequestBody = Utilities::splitStringIntoVector(postRequestBody, '&');
|
||||
for (string item : splitPostRequestBody) {
|
||||
vector<string> splitItem = Utilities::splitStringIntoVector(item, '=');
|
||||
if (splitItem.at(0) == "customername")
|
||||
newRequest.customerName = splitItem.at(1);
|
||||
if (splitItem.at(0) == "email")
|
||||
newRequest.customerEmailAddress = splitItem.at(1);
|
||||
if (splitItem.at(0) == "customercontactdetails")
|
||||
newRequest.customerContactDetails = splitItem.at(1);
|
||||
if (splitItem.at(0) == "requestdescription")
|
||||
newRequest.requestDescription = splitItem.at(1);
|
||||
if (splitItem.at(0) == "templateID")
|
||||
newRequest.templateID = stoi(splitItem.at(1));
|
||||
}
|
||||
|
||||
pqxx::connection databaseConnection(databaseURI);
|
||||
pqxx::result resultTemplate = Database::executePreparedStatement_SELECT_TEMPLATE_FLAT(databaseConnection, newRequest.templateID);
|
||||
|
||||
for (int i = 0; i < resultTemplate.columns(); ++i) {
|
||||
//freelancerid
|
||||
newRequest.freelancerID = stoi(resultTemplate.at(0).at(0).c_str());
|
||||
//currencypreference
|
||||
newRequest.currencyPreference = resultTemplate.at(0).at(1).c_str();
|
||||
//priceupfront
|
||||
newRequest.priceUpFront = resultTemplate.at(0).at(2).c_str();
|
||||
//priceondeliver
|
||||
newRequest.priceOnDeliver = resultTemplate.at(0).at(3).c_str();
|
||||
}
|
||||
newRequest.outputItem();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Utilities::sendEmail(configuration, "testfaewfaw@tempr.email", "NEW REQUEST", "NEW REQUEST");
|
||||
|
||||
string templateHTML = "customer_Freelancer_Template_Request_Fulfilment.html";
|
||||
auto page = crow::mustache::load(templateHTML);
|
||||
|
||||
return page.render();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user