2025-02-09 19:58:55 +01:00
|
|
|
#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)
|
2025-02-09 19:58:55 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2025-02-09 21:14:26 +01:00
|
|
|
void ActiveCommand::run(stringstream& args)
|
2025-02-09 19:58:55 +01:00
|
|
|
{
|
2025-02-09 23:22:43 +01:00
|
|
|
Manager* mgr = Manager::get_instance();
|
2025-02-09 19:58:55 +01:00
|
|
|
int user_id;
|
|
|
|
args >> user_id;
|
|
|
|
if (!user_id)
|
|
|
|
throw Error(102, "Ein Parameter eines Befehls konnte nicht gelesen werden");
|
2025-02-09 23:22:43 +01:00
|
|
|
const User* u = mgr->get_user(user_id);
|
2025-02-09 19:58:55 +01:00
|
|
|
if (!u)
|
|
|
|
throw Error(401, "Eine solche BenutzerIn existiert nicht.");
|
2025-02-09 23:22:43 +01:00
|
|
|
for (const Assignment* a : mgr->get_assignments_for_user(user_id))
|
2025-02-09 19:58:55 +01:00
|
|
|
cout << a->get_task_id() << "\n";
|
|
|
|
}
|
|
|
|
} // commands
|