-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileManager.cpp
More file actions
69 lines (55 loc) · 1.97 KB
/
FileManager.cpp
File metadata and controls
69 lines (55 loc) · 1.97 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
59
60
61
62
63
64
65
66
67
#include "FileManager.h"
#include "FilesHelper.h"
FileManager::FileManager() {
client_file = "Clients.txt";
employee_file = "Employees.txt";
admin_file = "Admins.txt";
client_file_last_id = "Last_id_Clients.txt";
employee_file_last_id = "Last_id_Employees.txt";
admin_file_last_id = "Last_id_Admins.txt";
ofstream client_out(client_file, ios::app);
client_out.close();
ofstream employee_out(employee_file, ios::app);
employee_out.close();
ofstream admin_out(admin_file, ios::app);
admin_out.close();
// ofstream client_out_lastID(client_file_last_id, ios::app);
// client_out_lastID.close();
// ofstream employee_out_lastID(employee_file_last_id, ios::app);
// employee_out_lastID.close();
// ofstream admin_out_lastID(admin_file_last_id, ios::app);
// admin_out_lastID.close();
}
void FileManager::add_client(Client &c, bool generateID) {
FilesHelper::saveClient(c, generateID);
}
void FileManager::add_employee(Employee &e, bool generateID) {
FilesHelper::saveEmployee(employee_file,employee_file_last_id,e, generateID);
}
void FileManager::add_admin(Admin &a, bool generateID) {
FilesHelper::saveEmployee(admin_file,admin_file_last_id,a, generateID);
}
vector<Client> FileManager::get_all_clients() {
return FilesHelper::getClients();
}
vector<Employee> FileManager::get_all_employees() {
return FilesHelper::getEmployees();
}
vector<Admin> FileManager::get_all_admins() {
return FilesHelper::getAdmins();
}
void FileManager::remove_all_clients() {
FilesHelper::clearFile(client_file,client_file_last_id);
}
void FileManager::remove_all_employees() {
FilesHelper::clearFile(employee_file,employee_file_last_id);
}
void FileManager::remove_all_admins() {
FilesHelper::clearFile(admin_file,admin_file_last_id);
}
Client *FileManager::search_client(int id) {
return FilesHelper::SearchClient(id);
}
Employee *FileManager::search_employee(int id) {
return FilesHelper::SearchEmployee(id);
}