diff --git a/include/orders.hpp b/include/orders.hpp index 3913f46..65b6555 100644 --- a/include/orders.hpp +++ b/include/orders.hpp @@ -12,6 +12,6 @@ public: void write(); void load(); orders(const with_data_directory &); - void push(); + void push(json); ~orders(); }; diff --git a/src/orders.cpp b/src/orders.cpp index c1c8e40..833f26d 100644 --- a/src/orders.cpp +++ b/src/orders.cpp @@ -38,3 +38,8 @@ void orders::write() { } orders::~orders() { write(); } + +void orders::push(json data) { + data["id"] = std::to_string(size() + 1); + push_back(data); +} \ No newline at end of file diff --git a/src/store.cpp b/src/store.cpp index c84b5bf..dac8464 100644 --- a/src/store.cpp +++ b/src/store.cpp @@ -86,7 +86,7 @@ int Application::run() { return response::bad_request(response, v.errors()); } - orders.push_back(data); + orders.push(data); orders.write(); response->write(Status::success_created, data.dump(),