cleanup articles

This commit is contained in:
Martin Brodbeck 2018-07-13 13:54:02 +02:00
parent ba86af4064
commit 9ec6ac383f
2 changed files with 15 additions and 2 deletions

View file

@ -49,4 +49,16 @@ int Seller::numArticlesSold() const { return static_cast<int>(getArticles(true).
int Seller::numArticlesOffered() const { return numArticlesOffered_; } int Seller::numArticlesOffered() const { return numArticlesOffered_; }
void Seller::cleanupArticles()
{
articles_.erase(std::remove_if(begin(articles_), end(articles_),
[](const std::shared_ptr<Article>& article) {
return article->getState() == Article::State::DELETE;
}));
for (auto& article : articles_) {
article->setState(Article::State::OK);
}
}
// int Seller::numArticlesTotal() const { return static_cast<int>(getArticles().size()); } // int Seller::numArticlesTotal() const { return static_cast<int>(getArticles().size()); }

View file

@ -22,6 +22,7 @@ class Seller : public Entity
void setLastName(const std::string& lastName); void setLastName(const std::string& lastName);
void setNumArticlesOffered(int number); void setNumArticlesOffered(int number);
void addArticle(std::shared_ptr<Article> article); void addArticle(std::shared_ptr<Article> article);
void cleanupArticles();
std::string getFirstName() const; std::string getFirstName() const;
std::string getLastName() const; std::string getLastName() const;