parent
ecd1111391
commit
01577d02a0
2 changed files with 26 additions and 17 deletions
|
@ -39,11 +39,6 @@ std::size_t CsvReader::readSellersFromFile(const fs::path &filePath, Marketplace
|
|||
continue;
|
||||
}
|
||||
|
||||
if (row[2].get<std::string>().empty() && row[3].get<std::string>().empty()) {
|
||||
++rowCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
auto seller = std::make_unique<Seller>();
|
||||
seller->setSellerNo(row[0].get<int>());
|
||||
if (row[1].is_int()) {
|
||||
|
@ -51,10 +46,19 @@ std::size_t CsvReader::readSellersFromFile(const fs::path &filePath, Marketplace
|
|||
} else {
|
||||
seller->setNumArticlesOffered(0);
|
||||
}
|
||||
|
||||
// If both, first name and last name, are empty, use N. N.
|
||||
// Else, use the real values.
|
||||
if (row[2].get<std::string>().empty() && row[3].get<std::string>().empty()) {
|
||||
seller->setFirstName("N.");
|
||||
seller->setLastName("N.");
|
||||
} else {
|
||||
std::string firstName = row[2].get<std::string>();
|
||||
seller->setFirstName(trim(firstName));
|
||||
std::string lastName = row[3].get<std::string>();
|
||||
seller->setLastName(trim(lastName));
|
||||
}
|
||||
|
||||
market->getSellers().push_back(std::move(seller));
|
||||
rowCount++;
|
||||
}
|
||||
|
|
|
@ -28,17 +28,22 @@ std::size_t ExcelReader::readSellersFromFile(const fs::path &filePath, Marketpla
|
|||
continue;
|
||||
}
|
||||
|
||||
// Skip the row if the seller has neither a first name nor a surname
|
||||
if (row[2].value<std::string>().empty() && row[3].value<std::string>().empty()) {
|
||||
continue;
|
||||
}
|
||||
auto seller = std::make_unique<Seller>();
|
||||
seller->setSellerNo(row[0].value<int>());
|
||||
seller->setNumArticlesOffered(row[1].value<int>());
|
||||
|
||||
// If both, first name and last name, are empty, use N. N.
|
||||
// Else, use the real values.
|
||||
if (row[2].value<std::string>().empty() && row[3].value<std::string>().empty()) {
|
||||
seller->setFirstName("N.");
|
||||
seller->setLastName("N.");
|
||||
} else {
|
||||
std::string firstName = row[2].value<std::string>();
|
||||
seller->setFirstName(trim(firstName));
|
||||
std::string lastName = row[3].value<std::string>();
|
||||
seller->setLastName(trim(lastName));
|
||||
}
|
||||
|
||||
market->getSellers().push_back(std::move(seller));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue