Minor fixes in employee listing and menus
<SRS> SRS02 : Employee Management </SRS> <Changes> - Sorted active employees by ID when listing - Handled empty employee lists in menus - Stopped deactivation when no employee is selected - Showed "NULL" when team ID is missing - Removed unnecessary error throw in payroll menu </Changes> <Review> Smitha Mohan </Review>
This commit is contained in:
@@ -49,9 +49,6 @@ void FinanceExecutiveMenu::updatePayroll()
|
||||
std::cout << "Payroll Updated";
|
||||
util::pressEnter();
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error("Unexpected error occured");
|
||||
}
|
||||
}
|
||||
|
||||
bool FinanceExecutiveMenu::handleOperation(int choice)
|
||||
|
||||
@@ -72,6 +72,12 @@ inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>>
|
||||
std::map<int, std::shared_ptr<const Employee>> employeeList;
|
||||
int index = 0;
|
||||
util::clear();
|
||||
if (allEmployees.empty())
|
||||
{
|
||||
std::cout << "No employees found!";
|
||||
util::pressEnter();
|
||||
return "";
|
||||
}
|
||||
std::cout << "Select the Employee\n";
|
||||
for (auto& currentEmployee : allEmployees)
|
||||
{
|
||||
@@ -109,16 +115,21 @@ inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>>
|
||||
|
||||
inline void deactivateEmployee(const std::shared_ptr<ZenvyController>& controller)
|
||||
{
|
||||
if(controller->deactivateEmployee(selectEmployeeId(controller->getEmployees())))
|
||||
{
|
||||
std::cout << "Employee deactivated successfully\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Employee not found\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
std::string selectedEmployeeId = selectEmployeeId(controller->getEmployees());
|
||||
if (selectedEmployeeId.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(controller->deactivateEmployee(selectedEmployeeId))
|
||||
{
|
||||
std::cout << "Employee deactivated successfully\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Employee not found\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
}
|
||||
|
||||
inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||
@@ -148,7 +159,7 @@ inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||
<< std::setw(25) << Enums::getEmployeeTypeString(iterator->getEmployeeType())
|
||||
<< std::setw(25) << iterator->getEmployeeEmail()
|
||||
<< std::setw(15) << iterator->getEmployeePhone()
|
||||
<< std::setw(10) << iterator->getEmployeeTeamId()
|
||||
<< std::setw(10) << (iterator->getEmployeeTeamId().empty() ? "NULL" : iterator->getEmployeeTeamId())
|
||||
<< std::endl;
|
||||
}
|
||||
util::pressEnter();
|
||||
|
||||
Reference in New Issue
Block a user