-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession.cpp
More file actions
58 lines (46 loc) · 1.59 KB
/
session.cpp
File metadata and controls
58 lines (46 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// Created by User on 7/12/2023.
//
#include "session.h"
#include <algorithm>
vector<string> Session::getVolunteersFromDepartment(string department) {
vector<string> volunteers;
for (auto vol : this->repository.getVolunteers())
if (vol.getDepartmentName() == department)
volunteers.push_back(vol.getVolunteer());
sort(volunteers.begin(), volunteers.end());
return volunteers;
}
vector<string> Session::getUnassigned() {
vector<string> volunteers;
for (auto vol : this->repository.getVolunteers())
if (vol.getDepartmentName() == "Unassigned")
volunteers.push_back(vol.getVolunteer());
sort(volunteers.begin(), volunteers.end());
return volunteers;
}
vector<pair<int, string>> Session::getStatistics() {
return vector<pair<int, string>>();
}
vector<string> Session::getMostSuitable(string description) {
return vector<string>();
}
void Session::addVolunteer(string name, string email, string interests, string department) {
this->repository.addVolunteer(name, email, interests, department);
this->notify();
}
void Session::assignVolunteer(string key, string department) {
istringstream iss(key);
const char sep = '|';
string name, email, interests;
getline(iss, name, sep);
getline(iss, email, sep);
getline(iss, interests, sep);
for (int i = 0; i < this->repository.getVolunteers().size(); i++)
if (this->repository.getVolunteers()[i].getVolunteer() == key)
{
this->repository.assignVolunteer(i, department);
this->notify();
break;
}
}