|
|
|
|
@ -36,6 +36,8 @@ int main()
|
|
|
|
|
crow::json::wvalue status;
|
|
|
|
|
auto request_body = crow::json::load(req.body);
|
|
|
|
|
|
|
|
|
|
if(request_body.has("comments")){
|
|
|
|
|
|
|
|
|
|
prep_stmt = con->prepareStatement("INSERT INTO practice_sessions (description, seconds, comments, practice_category_id) VALUES (?, ?, ?, ?)");
|
|
|
|
|
|
|
|
|
|
string description = request_body["description"].s();
|
|
|
|
|
@ -49,6 +51,21 @@ int main()
|
|
|
|
|
prep_stmt->setInt(4, practice_category_id);
|
|
|
|
|
prep_stmt->execute();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
prep_stmt = con->prepareStatement("INSERT INTO practice_sessions (description, seconds, practice_category_id) VALUES (?, ?, ?)");
|
|
|
|
|
|
|
|
|
|
string description = request_body["description"].s();
|
|
|
|
|
int seconds = request_body["seconds"].i();
|
|
|
|
|
int practice_category_id = request_body["practice_category_id"].i();
|
|
|
|
|
|
|
|
|
|
prep_stmt->setString(1, description);
|
|
|
|
|
prep_stmt->setInt(2, seconds);
|
|
|
|
|
prep_stmt->setInt(3, practice_category_id);
|
|
|
|
|
prep_stmt->execute();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status = {{"status", "success"}};
|
|
|
|
|
return status;
|
|
|
|
|
});
|
|
|
|
|
|