forked from University/epr24pr5-ojanssen2
Compare commits
No commits in common. "ca572b6fb542d5095f8a41c649e1f41496f81700" and "3ad11e7e11744b7766dc48112703b4c78c4838d4" have entirely different histories.
ca572b6fb5
...
3ad11e7e11
4 changed files with 7 additions and 33 deletions
|
@ -22,11 +22,7 @@ namespace commands
|
||||||
const User* u = mgr->get_user(user_id);
|
const User* u = mgr->get_user(user_id);
|
||||||
if (!u)
|
if (!u)
|
||||||
throw Error(401, "Eine solche BenutzerIn existiert nicht.");
|
throw Error(401, "Eine solche BenutzerIn existiert nicht.");
|
||||||
for (const Assignment* a : mgr->get_assignments_for_user(user_id)) {
|
for (const Assignment* a : mgr->get_assignments_for_user(user_id))
|
||||||
//Ist der Related Task ein Aktiver Task?
|
cout << a->get_task_id() << "\n";
|
||||||
if (mgr->get_task(a->get_task_id())->is_active()) {
|
|
||||||
cout << a->get_task_id() << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // commands
|
} // commands
|
||||||
|
|
|
@ -250,16 +250,12 @@ namespace util
|
||||||
throw Error(202, "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
|
//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 (Task* task : this->get_tasks()) {
|
||||||
for (int child_id : task->get_children()) {
|
for (int child_id : task->get_children()) {
|
||||||
if (id == child_id) {
|
if (id == child_id) {
|
||||||
throw Error(202, "Aufgabe kann nicht gelöscht werden.");
|
throw Error(202, "Aufgabe kann nicht gelöscht werden.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
if (! this->get_task(id)->is_active()) {
|
|
||||||
throw Error(202, "Aufgabe kann nicht gelöscht werden.");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this->tasks.erase(id);
|
this->tasks.erase(id);
|
||||||
}
|
}
|
||||||
|
@ -269,7 +265,7 @@ namespace util
|
||||||
if (!this->assignment_exists(as.get_user_id(), as.get_task_id()))
|
if (!this->assignment_exists(as.get_user_id(), as.get_task_id()))
|
||||||
throw Error(301, "Eine solche Zuordnung existiert nicht.");
|
throw Error(301, "Eine solche Zuordnung existiert nicht.");
|
||||||
int assignment_nr = 0;
|
int assignment_nr = 0;
|
||||||
for (int i = 0; i < this->assignments.size(); ++i) {
|
for (int i = 0; i < this->assignments.size() - 1; ++i) {
|
||||||
if (this->assignments[i]->get_user_id() == as.get_user_id() && this->assignments[i]->get_task_id() == as.get_task_id()) {
|
if (this->assignments[i]->get_user_id() == as.get_user_id() && this->assignments[i]->get_task_id() == as.get_task_id()) {
|
||||||
assignment_nr = i;
|
assignment_nr = i;
|
||||||
break;
|
break;
|
||||||
|
|
23
Task.cpp
23
Task.cpp
|
@ -31,26 +31,9 @@ namespace models
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Task::get_id() const { return this->id; }
|
int Task::get_id() const
|
||||||
|
{
|
||||||
/**
|
return this->id;
|
||||||
* Diese Methode überprüft ob der Task Aktiv ist ( Nicht Nachfolger einer anderen Klass ist)
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
bool Task::is_active() const {
|
|
||||||
|
|
||||||
Manager* mgr = Manager::get_instance();
|
|
||||||
for (Task* task : mgr->get_tasks()) {
|
|
||||||
for (int child_id : task->get_children()) {
|
|
||||||
// Aktiver Task ist Child von Einem andern Task -> Nicht aktiv
|
|
||||||
if (this->id == child_id) {
|
|
||||||
// cout << this->id << " = " << child_id << endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Kein Child-> Aktiv
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string Task::get_name() const
|
string Task::get_name() const
|
||||||
|
|
1
Task.h
1
Task.h
|
@ -28,7 +28,6 @@ namespace models
|
||||||
istream& read(istream&);
|
istream& read(istream&);
|
||||||
|
|
||||||
int get_id() const;
|
int get_id() const;
|
||||||
bool is_active() const;
|
|
||||||
string get_name() const;
|
string get_name() const;
|
||||||
string get_description() const;
|
string get_description() const;
|
||||||
vector<int> get_children() const;
|
vector<int> get_children() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue