forked from University/epr24pr5-ojanssen2
Fix Deletion Constraint (No Child)
This commit is contained in:
parent
7a35c951ed
commit
a8d390ffe3
1 changed files with 9 additions and 1 deletions
10
Manager.cpp
10
Manager.cpp
|
@ -247,7 +247,15 @@ namespace util
|
||||||
if (this->tasks.count(id) == 0)
|
if (this->tasks.count(id) == 0)
|
||||||
throw Error(402, "Eine solche Aufgabe existiert nicht.");
|
throw Error(402, "Eine solche Aufgabe existiert nicht.");
|
||||||
if (!this->get_assignments_for_task(id).empty()) {
|
if (!this->get_assignments_for_task(id).empty()) {
|
||||||
throw Error(201, "Aufgabe kann nicht gelöscht werden.");
|
throw Error(202, "Aufgabe kann nicht gelöscht werden.");
|
||||||
|
}
|
||||||
|
//TODO: Zudem kann eine Aufgabe nur gelöscht werden, wenn Sie nicht Nachfolgerin einer anderen Aufgabe ist -> Ensure its no Child
|
||||||
|
for (Task* task : this->get_tasks()) {
|
||||||
|
for (int child_id : task->get_children()) {
|
||||||
|
if (id == child_id) {
|
||||||
|
throw Error(202, "Aufgabe kann nicht gelöscht werden.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->tasks.erase(id);
|
this->tasks.erase(id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue