#include "service.h" #include Service::Service() { } Service::~Service() { } void Service::addTask(std::string description, int duration, std::string date) { Task task(description, duration, date); this->repo.addTask(task); } std::vector Service::getTasks() { auto tasks = this->repo.getTasks(); std::sort(tasks.begin(), tasks.end(), [](Task task1, Task task2) { if(task1.getDate() == task2.getDate()) return task1.getDuration() > task2.getDuration(); return task1.getDate() > task2.getDate(); }); return tasks; } std::vector Service::getTasksForDate(std::string date) { auto tasks = this->repo.getTasks(); std::vector filteredTasks; for (auto task : tasks) { if(task.getDate() == date) filteredTasks.push_back(task); } return filteredTasks; }