forked from University/epr24pr5-ojanssen2
29 lines
762 B
C++
29 lines
762 B
C++
|
#include "ActiveCommand.h"
|
||
|
#include "Error.h"
|
||
|
#include "Manager.h"
|
||
|
|
||
|
using util::Util;
|
||
|
using util::Manager;
|
||
|
using err::Error;
|
||
|
|
||
|
namespace commands
|
||
|
{
|
||
|
ActiveCommand::ActiveCommand() : SubCommand("active", 100, true)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void ActiveCommand::run(int argc, stringstream& args)
|
||
|
{
|
||
|
Manager& mgr = Manager::get_instance();
|
||
|
int user_id;
|
||
|
args >> user_id;
|
||
|
if (!user_id)
|
||
|
throw Error(102, "Ein Parameter eines Befehls konnte nicht gelesen werden");
|
||
|
User* u = mgr.get_user(user_id);
|
||
|
if (!u)
|
||
|
throw Error(401, "Eine solche BenutzerIn existiert nicht.");
|
||
|
for (Assignment* a : mgr.get_assignments_for_user(user_id))
|
||
|
cout << a->get_task_id() << "\n";
|
||
|
}
|
||
|
} // commands
|