b3b9299c70
<UserStory> EMP004 : Update Personal Details </UserStory> <Changes> - Added MenuHelper.cpp and MenuHelper.h and integrated them into project - Moved updateProfile() logic from individual menus into MenuHelper - Added inline updateProfile(shared_ptr<ZenvyController>) to MenuHelper - Updated AdminMenu, EmployeeMenu, HRManagerMenu, FinanceExecutiveMenu, ITExecutiveMenu, TalentExecutiveMenu, TeamExecutiveMenu, and TeamLeadMenu to use centralized updateProfile() - Added getCurrentEmployee() and updateProfile() to ZenvyController - Added corresponding implementations in EmployeeManagementService - Minor layout and option text improvements across all menus </Changes> <Review> Smitha Mohan </Review>
135 lines
2.9 KiB
C++
135 lines
2.9 KiB
C++
#include <iostream>
|
|
#include "AdminMenu.h"
|
|
#include "InputHelper.h"
|
|
#include "OutputHelper.h"
|
|
#include "MenuHelper.h"
|
|
|
|
static Enums::EmployeeType getEmployeeType()
|
|
{
|
|
int choice;
|
|
util::clear();
|
|
std::cout << "Select Employee Type"
|
|
"\n1. HR Employee"
|
|
"\n2. IT Executive"
|
|
"\n3. Team Executive"
|
|
"\n4. Finance Executive"
|
|
"\n5. Talent Executive"
|
|
"\n6. General Employee";
|
|
util::read(choice);
|
|
switch (choice)
|
|
{
|
|
case 1:
|
|
return Enums::EmployeeType::HR;
|
|
case 2:
|
|
return Enums::EmployeeType::IT;
|
|
case 3:
|
|
return Enums::EmployeeType::TEAM;
|
|
case 4:
|
|
return Enums::EmployeeType::FINANCE;
|
|
case 5:
|
|
return Enums::EmployeeType::TAG;
|
|
case 6:
|
|
return Enums::EmployeeType::GENERAL;
|
|
default:
|
|
return Enums::EmployeeType::INVALID;
|
|
}
|
|
}
|
|
|
|
static Enums::EmployeeDesignation getEmployeeDesignation()
|
|
{
|
|
int choice;
|
|
util::clear();
|
|
std::cout << "Select Employee Designation"
|
|
"\n1. SENIOR"
|
|
"\n2. JUNIOR";
|
|
util::read(choice);
|
|
switch (choice)
|
|
{
|
|
case 1:
|
|
return Enums::EmployeeDesignation::SENIOR;
|
|
case 2:
|
|
return Enums::EmployeeDesignation::JUNIOR;
|
|
default:
|
|
return Enums::EmployeeDesignation::INVALID;
|
|
}
|
|
}
|
|
|
|
static void createEmployee(std::shared_ptr<ZenvyController> controller)
|
|
{
|
|
Enums::EmployeeType employeeType = getEmployeeType();
|
|
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
|
|
std::string name, email, phone;
|
|
switch (employeeType)
|
|
{
|
|
case Enums::EmployeeType::INVALID:
|
|
std::cout << "Invalid Choice";
|
|
util::pressEnter();
|
|
return;
|
|
case Enums::EmployeeType::GENERAL:
|
|
employeeDesignation = getEmployeeDesignation();
|
|
if (employeeDesignation == Enums::EmployeeDesignation::INVALID)
|
|
{
|
|
std::cout << "Invalid Choice";
|
|
util::pressEnter();
|
|
return;
|
|
}
|
|
break;
|
|
}
|
|
std::cout << "Enter Name: ";
|
|
util::read(name);
|
|
std::cout << "Enter Email: ";
|
|
util::read(email);
|
|
std::cout << "Enter Phone: ";
|
|
util::read(phone);
|
|
controller->createEmployee(employeeType, employeeDesignation, name, email, phone);
|
|
std::cout << "\nCreated Employee Successfully.";
|
|
}
|
|
|
|
void AdminMenu::run()
|
|
{
|
|
bool isMenuActive = true;
|
|
while (isMenuActive)
|
|
{
|
|
try
|
|
{
|
|
int choice;
|
|
util::clear();
|
|
std::cout << "Admin Menu\n1. Create User\n2. View Employee\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Logout\nEnter your Choice: ";
|
|
util::read(choice);
|
|
if (!handleOperation(choice))
|
|
{
|
|
isMenuActive = false;
|
|
}
|
|
}
|
|
catch (const std::exception& e)
|
|
{
|
|
std::cout << "Exception: " << e.what() << std::endl;
|
|
util::pressEnter();
|
|
}
|
|
}
|
|
}
|
|
|
|
bool AdminMenu::handleOperation(int choice)
|
|
{
|
|
switch (choice)
|
|
{
|
|
case 1:
|
|
createEmployee(m_zenvyController);
|
|
break;
|
|
/*case 2:
|
|
m_zenvyController.viewEmployee();
|
|
break;
|
|
case 3:
|
|
m_zenvyController.deactivateEmployee();
|
|
break;*/
|
|
case 5:
|
|
updateProfile(m_zenvyController);
|
|
break;
|
|
case 6:
|
|
return false;
|
|
default:
|
|
std::cout << "Enter a valid choice!" << std::endl;
|
|
}
|
|
return true;
|
|
}
|