#pragma once #include #include #include #include #include "DataStore.h" #include "Enums.h" #include "StringHelper.h" using Employees = std::vector>; class EmployeeManagementService { private: DataStore& m_dataStore; public: EmployeeManagementService() : m_dataStore(DataStore::getInstance()) {}; void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&); bool deactivateEmployee(const std::string&); bool updateDesignation(const std::string&,Enums::EmployeeDesignation); void updateProfile(const std::string&,const std::string&); std::pair>> searchEmployee(const std::string&); std::shared_ptr getCurrentEmployee(); std::vector> getShorlistedCandidates(); void loadEmployees(); void saveEmployees(); template Employees getEmployees(Types... types) { Employees filteredEmployees; const auto& employees = m_dataStore.getEmployees(); std::vector filterTypes = { types... }; for (const auto& employeePair : employees) { const auto& employee = employeePair.second; if (employee->getEmployeeAccountStatus() != Enums::AccountStatus::ACTIVE) continue; auto employeeType = employee->getEmployeeType(); if (filterTypes.empty()) { if (employeeType == Enums::EmployeeType::ADMIN) continue; } else { if (std::find(filterTypes.begin(), filterTypes.end(), employeeType) == filterTypes.end()) continue; } filteredEmployees.push_back(employee); } std::sort( filteredEmployees.begin(), filteredEmployees.end(), [](const std::shared_ptr& employeeOne, const std::shared_ptr& employeeTwo) { return util::extractNumber(employeeOne->getId()) < util::extractNumber(employeeTwo->getId()); } ); return filteredEmployees; } };