Files
School/Anul 1/Semestrul 2/OOP/Labs/t3-DanielCujba/service.cpp
T
2024-08-31 12:07:21 +03:00

40 lines
803 B
C++

#include "service.h"
#include <algorithm>
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<Task> 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<Task> Service::getTasksForDate(std::string date)
{
auto tasks = this->repo.getTasks();
std::vector<Task> filteredTasks;
for (auto task : tasks) {
if(task.getDate() == date)
filteredTasks.push_back(task);
}
return filteredTasks;
}