Add Update Designation functionality for General Employees
<UserStory> EMP005 : Update Designation </UserStory> <Changes> - Added updateDesignation method in ZenvyController and EmployeeManagementService. - Implemented update designation logic with authorization checks. - Enabled Admin menu option to update employee designation - Display employee designation in employee selection list - Extended GeneralEmployee to expose and update designation - Integrated role selection flow in MenuHelper. </Changes> <Review> Smitha Mohan </Review>
This commit is contained in:
@@ -13,7 +13,7 @@ void AdminMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Admin Menu\n1. Create User\n2. View Employees\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Logout\nEnter your Choice: ";
|
||||
std::cout << "Admin Menu\n1. Create User\n2. View Employees\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Update Designation \n7. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -48,6 +48,9 @@ bool AdminMenu::handleOperation(int choice)
|
||||
updateProfile(m_zenvyController);
|
||||
break;
|
||||
case 6:
|
||||
updateDesignation(m_zenvyController);
|
||||
break;
|
||||
case 7:
|
||||
return false;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
|
||||
@@ -102,3 +102,23 @@ void createEmployee(std::shared_ptr<ZenvyController> controller)
|
||||
std::cout << "\nCreated Employee Successfully.";
|
||||
util::pressEnter();
|
||||
}
|
||||
|
||||
void updateDesignation(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||
{
|
||||
std::string selectedEmployeeId = selectEmployeeId(m_zenvyController->getEmployees(Enums::EmployeeType::GENERAL));
|
||||
if (selectedEmployeeId.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Enums::EmployeeDesignation designation = getEmployeeDesignation();
|
||||
if (m_zenvyController->updateDesignation(selectedEmployeeId, designation))
|
||||
{
|
||||
std::cout << "Assign Employee Role successfull\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Employee not found\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Validator.h"
|
||||
|
||||
void createEmployee(std::shared_ptr<ZenvyController> controller);
|
||||
void updateDesignation(std::shared_ptr<ZenvyController> m_zenvyController);
|
||||
|
||||
inline void viewProfile(std::shared_ptr<ZenvyController> controller)
|
||||
{
|
||||
@@ -134,14 +135,31 @@ inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>>
|
||||
<< std::setw(10) << "Index"
|
||||
<< std::setw(15) << "Employee ID"
|
||||
<< std::setw(20) << "Name"
|
||||
<< std::setw(20) << "Employee Type" << std::endl;
|
||||
<< std::setw(20) << "Employee Type"
|
||||
<< std::setw(20) << "Employee Designation" << std::endl;
|
||||
for (const auto& employee : employeeList)
|
||||
{
|
||||
std::cout << std::left << std::setw(10) << employee.first
|
||||
<< std::setw(15) << employee.second->getId()
|
||||
<< std::setw(20) << employee.second->getEmployeeName()
|
||||
<< std::setw(20) << Enums::getEmployeeTypeString(employee.second->getEmployeeType())
|
||||
<< std::endl;
|
||||
auto generalEmployee = std::dynamic_pointer_cast<const GeneralEmployee>(employee.second);
|
||||
if (generalEmployee)
|
||||
{
|
||||
std::cout << std::left
|
||||
<< std::setw(10) << employee.first
|
||||
<< std::setw(15) << generalEmployee->getId()
|
||||
<< std::setw(20) << generalEmployee->getEmployeeName()
|
||||
<< std::setw(20) << Enums::getEmployeeTypeString(generalEmployee->getEmployeeType())
|
||||
<< std::setw(20) << Enums::getEmployeeDesignationString(generalEmployee->getDesignation())
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << std::left
|
||||
<< std::setw(10) << employee.first
|
||||
<< std::setw(15) << employee.second->getId()
|
||||
<< std::setw(20) << employee.second->getEmployeeName()
|
||||
<< std::setw(20) << Enums::getEmployeeTypeString(employee.second->getEmployeeType())
|
||||
<< std::setw(20) << "NULL"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << "Enter the Index: ";
|
||||
util::read(choice);
|
||||
@@ -163,7 +181,7 @@ inline void deactivateEmployee(const std::shared_ptr<ZenvyController>& controlle
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(controller->deactivateEmployee(selectedEmployeeId))
|
||||
if (controller->deactivateEmployee(selectedEmployeeId))
|
||||
{
|
||||
std::cout << "Employee deactivated successfully\n";
|
||||
util::pressEnter();
|
||||
@@ -210,13 +228,13 @@ inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||
|
||||
inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
||||
{
|
||||
std::string name;
|
||||
util::clear();
|
||||
std::cout << "Enter Employee Name: ";
|
||||
util::read(name);
|
||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchResults = m_zenvyController->searchEmployee(name);
|
||||
if (!(searchResults.second).empty())
|
||||
{
|
||||
std::string name;
|
||||
util::clear();
|
||||
std::cout << "Enter Employee Name: ";
|
||||
util::read(name);
|
||||
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchResults = m_zenvyController->searchEmployee(name);
|
||||
if (!(searchResults.second).empty())
|
||||
{
|
||||
std::cout << std::left
|
||||
<< std::setw(10) << "ID"
|
||||
<< std::setw(20) << "Name"
|
||||
@@ -238,10 +256,10 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
||||
<< std::setw(15) << "HouseRentAllowance";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
for (const auto& employee : searchResults.second)
|
||||
{
|
||||
if (employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
|
||||
{
|
||||
for (const auto& employee : searchResults.second)
|
||||
{
|
||||
if (employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
|
||||
{
|
||||
std::cout << std::left
|
||||
<< std::setw(10) << employee->getId()
|
||||
<< std::setw(20) << employee->getEmployeeName()
|
||||
@@ -257,8 +275,8 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
||||
{
|
||||
std::cout << std::setw(15) << employee->getEmployeeTeamId();
|
||||
}
|
||||
if (searchResults.first == Enums::EmployeeType::FINANCE
|
||||
|| searchResults.first == Enums::EmployeeType::HR
|
||||
if (searchResults.first == Enums::EmployeeType::FINANCE
|
||||
|| searchResults.first == Enums::EmployeeType::HR
|
||||
|| searchResults.first == Enums::EmployeeType::ADMIN)
|
||||
{
|
||||
std::cout << std::left
|
||||
@@ -270,12 +288,13 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
||||
<< std::setw(15) << employee->getPayroll()->getHouseRentAllowance();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "No Employee found with this name" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "No Employee found with this name" << std::endl;
|
||||
}
|
||||
util::pressEnter();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user