-if (store->DelTariff(name))
- {
- WriteServLog("Cannot delete tariff %s.", name.c_str());
- WriteServLog("%s", store->GetStrError().c_str());
- return -1;
+ const auto ti = find(tariffs.begin(), tariffs.end(), TariffImpl(name));
+
+ if (ti == tariffs.end())
+ {
+ strError = "Tariff \'" + name + "\' cannot be deleted. Tariff does not exist.";
+ WriteServLog("%s %s", admin->logStr().c_str(), strError.c_str());
+ return -1;
+ }
+
+ if (store->DelTariff(name))
+ {
+ WriteServLog("Cannot delete tariff %s.", name.c_str());
+ WriteServLog("%s", store->GetStrError().c_str());
+ return -1;
+ }
+
+ td = ti->GetTariffData();
+
+ tariffs.erase(ti);