KIMA2 ist ein kleines Kassenprogramm für Kindersachenmärkte.
https://www.rustysoft.de/?01_kima2
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
992 B
41 lines
992 B
#include "marketplace.h" |
|
#include "database.h" |
|
|
|
#include <algorithm> |
|
|
|
Marketplace::Marketplace() |
|
{ |
|
auto seller = std::make_unique<Seller>("Max", "Mustermann"); |
|
seller->createUuid(); |
|
sellers_.push_back(std::move(seller)); |
|
} |
|
|
|
void Marketplace::storeToDb() |
|
{ |
|
Database db; |
|
db.storeSellers(sellers_); |
|
} |
|
|
|
void Marketplace::loadFromDb() |
|
{ |
|
Database db; |
|
db.loadSellers(sellers_); |
|
} |
|
|
|
std::vector<std::unique_ptr<Seller>>& Marketplace::getSellers() { return sellers_; } |
|
|
|
int Marketplace::getNextSellerNo() |
|
{ |
|
auto iter = std::max_element( |
|
sellers_.begin(), sellers_.end(), |
|
[](const std::unique_ptr<Seller>& a, const std::unique_ptr<Seller>& b) -> bool { |
|
return a->getSellerNo() < b->getSellerNo(); |
|
}); |
|
return (*iter)->getSellerNo() + 1; |
|
} |
|
|
|
int Marketplace::getNumSellersDelete() |
|
{ |
|
int count = std::count_if(sellers_.begin(), sellers_.end(), [](const auto& a){return a->getState() == Seller::State::DELETE;}); |
|
return count; |
|
} |