epr24pr5-ojanssen2/ActiveCommand.cpp

29 lines
762 B
C++
Raw Normal View History

#include "ActiveCommand.h"
#include "Error.h"
#include "Manager.h"
using util::Util;
using util::Manager;
using err::Error;
namespace commands
{
2025-02-09 22:30:03 +01:00
ActiveCommand::ActiveCommand() : SubCommand("active", false)
{
}
void ActiveCommand::run(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");
const User* u = mgr->get_user(user_id);
if (!u)
throw Error(401, "Eine solche BenutzerIn existiert nicht.");
for (const Assignment* a : mgr->get_assignments_for_user(user_id))
cout << a->get_task_id() << "\n";
}
} // commands