forked from University/epr24pr5-ojanssen2
31 lines
760 B
C++
31 lines
760 B
C++
#include "DelCommand.h"
|
|
#include "Error.h"
|
|
#include "Manager.h"
|
|
|
|
using util::Util;
|
|
using util::Manager;
|
|
using err::Error;
|
|
|
|
namespace commands
|
|
{
|
|
DelCommand::DelCommand() : SubCommand("delete", 100, true)
|
|
{
|
|
}
|
|
|
|
void DelCommand::run(stringstream& args)
|
|
{
|
|
Manager& mgr = Manager::get_instance();
|
|
const string data_type = Util::read_string(args);
|
|
int id;
|
|
args >> id;
|
|
if (!args)
|
|
throw Error(102, "Ein Parameter eines Befehls konnte nicht gelesen werden");
|
|
if (data_type == "user")
|
|
mgr.del_user(id);
|
|
else if (data_type == "task")
|
|
mgr.del_task(id);
|
|
else
|
|
throw Error(101, "Befehl ist unbekannt.");
|
|
mgr.save();
|
|
}
|
|
} // commands
|