Refactor shortlisted candidates access and fix index check
<UserStory> EMP0012 : Employee Management </UserStory> <Changes> - Changed getShorlistedCandidates() to return by value instead of reference - Updated controller and service method signatures accordingly - Fixed off-by-one error when selecting shortlisted candidate </Changes> <Review> Smitha Mohan </Review>
This commit is contained in:
@@ -47,7 +47,7 @@ bool ZenvyController::updateDesignation(const std::string& id,Enums::EmployeeDes
|
|||||||
return m_employeeManagementService->updateDesignation(id,designation);
|
return m_employeeManagementService->updateDesignation(id,designation);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Candidate>>& ZenvyController::getShorlistedCandidates()
|
std::vector<std::shared_ptr<Candidate>> ZenvyController::getShorlistedCandidates()
|
||||||
{
|
{
|
||||||
return m_employeeManagementService->getShorlistedCandidates();
|
return m_employeeManagementService->getShorlistedCandidates();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
void updateProfile(const std::string&,const std::string&);
|
void updateProfile(const std::string&,const std::string&);
|
||||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(const std::string&);
|
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(const std::string&);
|
||||||
bool updateDesignation(const std::string&,Enums::EmployeeDesignation);
|
bool updateDesignation(const std::string&,Enums::EmployeeDesignation);
|
||||||
std::vector<std::shared_ptr<Candidate>>& getShorlistedCandidates();
|
std::vector<std::shared_ptr<Candidate>> getShorlistedCandidates();
|
||||||
|
|
||||||
template <typename ...Types>
|
template <typename ...Types>
|
||||||
Employees getEmployees(Types ...types)
|
Employees getEmployees(Types ...types)
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ void EmployeeManagementService::saveEmployees()
|
|||||||
generalEmployeeFileManager.save(generalEmployees);
|
generalEmployeeFileManager.save(generalEmployees);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Candidate>>& EmployeeManagementService::getShorlistedCandidates()
|
std::vector<std::shared_ptr<Candidate>> EmployeeManagementService::getShorlistedCandidates()
|
||||||
{
|
{
|
||||||
candidateMap candidates = m_dataStore.getCandidates();
|
candidateMap candidates = m_dataStore.getCandidates();
|
||||||
std::vector<std::shared_ptr<Candidate>> shortlistedCandidates;
|
std::vector<std::shared_ptr<Candidate>> shortlistedCandidates;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
void updateProfile(const std::string&,const std::string&);
|
void updateProfile(const std::string&,const std::string&);
|
||||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(const std::string&);
|
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(const std::string&);
|
||||||
std::shared_ptr<const Employee> getCurrentEmployee();
|
std::shared_ptr<const Employee> getCurrentEmployee();
|
||||||
std::vector<std::shared_ptr<Candidate>>& getShorlistedCandidates();
|
std::vector<std::shared_ptr<Candidate>> getShorlistedCandidates();
|
||||||
void loadEmployees();
|
void loadEmployees();
|
||||||
void saveEmployees();
|
void saveEmployees();
|
||||||
|
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ void addShortlistedCandidateAsEmployee(const std::shared_ptr<ZenvyController>& c
|
|||||||
auto currentEmployee = controller->getCurrentEmployee();
|
auto currentEmployee = controller->getCurrentEmployee();
|
||||||
Enums::EmployeeType employeeType;
|
Enums::EmployeeType employeeType;
|
||||||
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
|
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
|
||||||
if (index > 0 && index < shortlistedCandidates.size())
|
if (index > 0 && index <= shortlistedCandidates.size())
|
||||||
{
|
{
|
||||||
employeeType = getEmployeeType(currentEmployee->getEmployeeType());
|
employeeType = getEmployeeType(currentEmployee->getEmployeeType());
|
||||||
std::shared_ptr<Candidate> candidate = shortlistedCandidates[index - 1];
|
std::shared_ptr<Candidate> candidate = shortlistedCandidates[index - 1];
|
||||||
|
|||||||
Reference in New Issue
Block a user