Updated Menu Helper and all User Menu

<UserStory> EMP006 : Search Employee </UserStory>

<Changes>
- Updated MenuHelper.h helper file for input validation
- Updated search employee logic in employee management service
- Removed comments in Enums.h and EmployeeManagementService.h
- Included MenuHelper.h in all User Menu files
</Changes>

<Review>
Smitha Mohan
</Review>
This commit is contained in:
Ajmal Jalaludeen
2026-04-08 10:19:21 +05:30
parent 47a9065c3b
commit a3e622ff8e
19 changed files with 162 additions and 191 deletions
@@ -26,13 +26,13 @@ std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> Emp
const auto& employee = entry.second; const auto& employee = entry.second;
if (!employee) if (!employee)
{ {
continue; // skip if pointer is null continue;
} }
std::string employeeName = employee->getEmployeeName(); std::string employeeName = employee->getEmployeeName();
std::transform(employeeName.begin(), employeeName.end(), employeeName.begin(), ::tolower); std::transform(employeeName.begin(), employeeName.end(), employeeName.begin(), ::tolower);
std::string searchName = name; std::string searchName = name;
std::transform(searchName.begin(), searchName.end(), searchName.begin(), ::tolower); std::transform(searchName.begin(), searchName.end(), searchName.begin(), ::tolower);
if (employeeName == searchName) if (employeeName.find(searchName) != std::string::npos)
{ {
employeeList.push_back(employee); employeeList.push_back(employee);
} }
+158 -120
View File
@@ -91,7 +91,148 @@ namespace Enums {
INVALID_PASSWORD INVALID_PASSWORD
}; };
/*std::string getEmployeeType(EmployeeType type) std::string getAccountStatus(AccountStatus status)
{
switch (status)
{
case AccountStatus::ACTIVE:
return "Active";
case AccountStatus::INACTIVE:
return "Inactive";
default:
return "Unknown";
}
}
std::string getTeamStatus(TeamStatus status)
{
switch (status)
{
case TeamStatus::IN_TEAM:
return "In Team";
case TeamStatus::NOT_IN_TEAM:
return "Not in Team";
default:
return "Unknown";
}
}
std::string getCandidateStatus(CandidateStatus status)
{
switch (status)
{
case CandidateStatus::PENDING: return "Pending";
case CandidateStatus::SHORTLISTED: return "Shortlisted";
case CandidateStatus::REJECTED: return "Rejected";
default: return "Unknown";
}
}
std::string getNotificationStatus(NotificationStatus status) {
switch (status)
{
case NotificationStatus::READ:
return "Read";
case NotificationStatus::UNREAD:
return "Unread";
default:
return "Unknown";
}
}
std::string getLeaveStatus(LeaveStatus status)
{
switch (status)
{
case LeaveStatus::PENDING:
return "Pending";
case LeaveStatus::APPROVED:
return "Approved";
case LeaveStatus::REJECTED:
return "Rejected";
default:
return "Unknown";
}
}
std::string getLeaveType(LeaveType type)
{
switch (type)
{
case LeaveType::GENERAL:
return "General Leave";
case LeaveType::MEDICAL:
return "Medical Leave";
case LeaveType::RESTRICTED:
return "Restricted Leave";
default:
return "Unknown";
}
}
std::string getJobListingStatus(JobListingStatus status)
{
switch (status)
{
case JobListingStatus::OPEN:
return "Open";
case JobListingStatus::CLOSED:
return "Closed";
default:
return "Unknown";
}
}
std::string getTicketStatus(TicketStatus status)
{
switch (status)
{
case TicketStatus::OPEN:
return "Open";
case TicketStatus::RESOLVED:
return "Resolved";
case TicketStatus::CLOSED:
return "Closed";
default:
return "Unknown";
}
}
std::string getTicketType(TicketType type)
{
switch (type)
{
case TicketType::IT:
return "IT";
case TicketType::FINANCE:
return "Finance";
case TicketType::ATTENDANCE:
return "Attendance";
case TicketType::UNKNOWN:
return "Unknown";
default:
return "Unknown";
}
}
std::string getEmployeeDesignation(EmployeeDesignation designation)
{
switch (designation)
{
case EmployeeDesignation::JUNIOR:
return "Junior";
case EmployeeDesignation::SENIOR:
return "Senior";
case EmployeeDesignation::TEAM_LEAD:
return "Team Lead";
case EmployeeDesignation::INVALID:
return "Invalid";
default:
return "Unknown";
}
}
std::string getEmployeeType(EmployeeType type)
{ {
switch (type) switch (type)
{ {
@@ -109,130 +250,27 @@ namespace Enums {
return "Talent Acquisition Executive"; return "Talent Acquisition Executive";
case EmployeeType::GENERAL: case EmployeeType::GENERAL:
return "General Employee"; return "General Employee";
default: case EmployeeType::INVALID:
return "Invalid"; return "Invalid";
default:
return "Unknown";
} }
} }
std::string getTeamStatus(TeamStatus status) std::string getLoginStatus(LoginStatus status)
{ {
switch (status)
}*/ {
case LoginStatus::SUCCESS:
std::string getAccountStatus(AccountStatus status) { return "Login Success";
switch (status) { case LoginStatus::FIRST_LOGIN:
case AccountStatus::ACTIVE: return "Active"; return "First Login";
case AccountStatus::INACTIVE: return "Inactive"; case LoginStatus::USER_NOT_FOUND:
default: return "Unknown"; return "User Not Found";
} case LoginStatus::INVALID_PASSWORD:
} return "Invalid Password";
default:
std::string getTeamStatus(TeamStatus status) { return "Unknown";
switch (status) {
case TeamStatus::IN_TEAM: return "In Team";
case TeamStatus::NOT_IN_TEAM: return "Not in Team";
default: return "Unknown";
}
}
std::string getCandidateStatus(CandidateStatus status) {
switch (status) {
case CandidateStatus::PENDING: return "Pending";
case CandidateStatus::SHORTLISTED: return "Shortlisted";
case CandidateStatus::REJECTED: return "Rejected";
default: return "Unknown";
}
}
std::string getNotificationStatus(NotificationStatus status) {
switch (status) {
case NotificationStatus::READ: return "Read";
case NotificationStatus::UNREAD: return "Unread";
default: return "Unknown";
}
}
std::string getLeaveStatus(LeaveStatus status) {
switch (status) {
case LeaveStatus::PENDING: return "Pending";
case LeaveStatus::APPROVED: return "Approved";
case LeaveStatus::REJECTED: return "Rejected";
default: return "Unknown";
}
}
std::string getLeaveType(LeaveType type) {
switch (type) {
case LeaveType::GENERAL: return "General Leave";
case LeaveType::MEDICAL: return "Medical Leave";
case LeaveType::RESTRICTED: return "Restricted Leave";
default: return "Unknown";
}
}
std::string getJobListingStatus(JobListingStatus status) {
switch (status) {
case JobListingStatus::OPEN: return "Open";
case JobListingStatus::CLOSED: return "Closed";
default: return "Unknown";
}
}
std::string getTicketStatus(TicketStatus status) {
switch (status) {
case TicketStatus::OPEN: return "Open";
case TicketStatus::RESOLVED: return "Resolved";
case TicketStatus::CLOSED: return "Closed";
default: return "Unknown";
}
}
std::string getTicketType(TicketType type) {
switch (type) {
case TicketType::IT: return "IT";
case TicketType::FINANCE: return "Finance";
case TicketType::ATTENDANCE: return "Attendance";
case TicketType::UNKNOWN: return "Unknown";
default: return "Unknown";
}
}
std::string getEmployeeDesignation(EmployeeDesignation designation) {
switch (designation) {
case EmployeeDesignation::JUNIOR: return "Junior";
case EmployeeDesignation::SENIOR: return "Senior";
case EmployeeDesignation::TEAM_LEAD: return "Team Lead";
case EmployeeDesignation::INVALID: return "Invalid";
default: return "Unknown";
}
}
std::string getEmployeeType(EmployeeType type) {
switch (type) {
case EmployeeType::HR: return "HR Manager";
case EmployeeType::TEAM: return "Team Executive";
case EmployeeType::ADMIN: return "Admin";
case EmployeeType::IT: return "IT Executive";
case EmployeeType::FINANCE: return "Finance Executive";
case EmployeeType::TAG: return "Talent Acquisition Executive";
case EmployeeType::GENERAL: return "General Employee";
case EmployeeType::INVALID: return "Invalid";
default: return "Unknown";
}
}
std::string getLoginStatus(LoginStatus status) {
switch (status) {
case LoginStatus::SUCCESS: return "Login Success";
case LoginStatus::FIRST_LOGIN: return "First Login";
case LoginStatus::USER_NOT_FOUND: return "User Not Found";
case LoginStatus::INVALID_PASSWORD: return "Invalid Password";
default: return "Unknown";
} }
} }
} }
namespace Enums {
}
@@ -45,7 +45,7 @@ bool AdminMenu::handleOperation(int choice)
m_zenvyController.deactivateEmployee(); m_zenvyController.deactivateEmployee();
break;*/ break;*/
case 5: case 5:
searchEmployee(); searchEmployee(m_zenvyController);
break; break;
case 6: case 6:
return false; return false;
@@ -55,10 +55,3 @@ bool AdminMenu::handleOperation(int choice)
return true; return true;
} }
void AdminMenu::searchEmployee()
{
std::string name;
std::cout << "Enter Employee Name: ";
util::read(name);
searchTheEmployee(name, m_zenvyController);
}
@@ -1,6 +1,5 @@
#pragma once #pragma once
#include<memory> #include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h" #include"ZenvyController.h"
class AdminMenu class AdminMenu
@@ -11,6 +10,5 @@ public:
AdminMenu() :m_zenvyController(std::make_shared<ZenvyController>()) {}; AdminMenu() :m_zenvyController(std::make_shared<ZenvyController>()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
void searchEmployee();
}; };
@@ -2,6 +2,7 @@
#include "EmployeeMenu.h" #include "EmployeeMenu.h"
#include"InputHelper.h" #include"InputHelper.h"
#include"OutputHelper.h" #include"OutputHelper.h"
#include "MenuHelper.h"
void EmployeeMenu::run() void EmployeeMenu::run()
{ {
@@ -53,7 +54,7 @@ bool EmployeeMenu::handleOperation(int choice)
m_zenvyController.viewEmployees(); m_zenvyController.viewEmployees();
break;*/ break;*/
case 8: case 8:
searchEmployee(); searchEmployee(m_zenvyController);
break; break;
/*case 9: /*case 9:
m_zenvyController.viewTeamMembers(); m_zenvyController.viewTeamMembers();
@@ -77,10 +78,4 @@ bool EmployeeMenu::handleOperation(int choice)
} }
return true; return true;
} }
void EmployeeMenu::searchEmployee()
{
std::string name;
std::cout << "Enter Employee Name: ";
util::read(name);
searchTheEmployee(name, m_zenvyController);
}
@@ -1,7 +1,5 @@
#pragma once #pragma once
#include<memory> #include<memory>
#include <iomanip>
#include "MenuHelper.h"
#include"ZenvyController.h" #include"ZenvyController.h"
class EmployeeMenu class EmployeeMenu
@@ -12,6 +10,5 @@ public:
EmployeeMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; EmployeeMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
void searchEmployee();
}; };
@@ -2,6 +2,7 @@
#include "FinanceExecutiveMenu.h" #include "FinanceExecutiveMenu.h"
#include"InputHelper.h" #include"InputHelper.h"
#include"OutputHelper.h" #include"OutputHelper.h"
#include "MenuHelper.h"
void FinanceExecutiveMenu::run() void FinanceExecutiveMenu::run()
{ {
@@ -44,7 +45,7 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
m_zenvyController.viewEmployees(); m_zenvyController.viewEmployees();
break;*/ break;*/
case 5: case 5:
searchEmployee(); searchEmployee(m_zenvyController);
break; break;
/*case 6: /*case 6:
m_zenvyController.viewNotifications(); m_zenvyController.viewNotifications();
@@ -68,11 +69,3 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
} }
return true; return true;
} }
void FinanceExecutiveMenu::searchEmployee()
{
std::string name;
std::cout << "Enter Employee Name: ";
util::read(name);
searchTheEmployee(name, m_zenvyController);
}
@@ -1,6 +1,5 @@
#pragma once #pragma once
#include<memory> #include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h" #include"ZenvyController.h"
class FinanceExecutiveMenu class FinanceExecutiveMenu
@@ -11,6 +10,5 @@ public:
FinanceExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; FinanceExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
void searchEmployee();
}; };
@@ -2,6 +2,7 @@
#include "HRManagerMenu.h" #include "HRManagerMenu.h"
#include"InputHelper.h" #include"InputHelper.h"
#include"OutputHelper.h" #include"OutputHelper.h"
#include "MenuHelper.h"
void HRManagerMenu::run() void HRManagerMenu::run()
{ {
@@ -44,7 +45,7 @@ bool HRManagerMenu::handleOperation(int choice)
m_zenvyController.viewEmployees(); m_zenvyController.viewEmployees();
break;*/ break;*/
case 5: case 5:
searchEmployee(); searchEmployee(m_zenvyController);
break; break;
/*case 6: /*case 6:
m_zenvyController.viewNotifications(); m_zenvyController.viewNotifications();
@@ -71,11 +72,3 @@ bool HRManagerMenu::handleOperation(int choice)
} }
return true; return true;
} }
void HRManagerMenu::searchEmployee()
{
std::string name;
std::cout << "Enter Employee Name: ";
util::read(name);
searchTheEmployee(name, m_zenvyController);
}
@@ -1,6 +1,5 @@
#pragma once #pragma once
#include<memory> #include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h" #include"ZenvyController.h"
class HRManagerMenu class HRManagerMenu
@@ -11,6 +10,5 @@ public:
HRManagerMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; HRManagerMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
void searchEmployee();
}; };
@@ -2,6 +2,7 @@
#include "ITExecutiveMenu.h" #include "ITExecutiveMenu.h"
#include"InputHelper.h" #include"InputHelper.h"
#include"OutputHelper.h" #include"OutputHelper.h"
#include "MenuHelper.h"
void ITExecutiveMenu::run() void ITExecutiveMenu::run()
{ {
@@ -44,7 +45,7 @@ bool ITExecutiveMenu::handleOperation(int choice)
m_zenvyController.viewEmployees(); m_zenvyController.viewEmployees();
break;*/ break;*/
case 5: case 5:
searchEmployee(); searchEmployee(m_zenvyController);
break; break;
/*case 6: /*case 6:
m_zenvyController.viewNotifications(); m_zenvyController.viewNotifications();
@@ -62,11 +63,3 @@ bool ITExecutiveMenu::handleOperation(int choice)
} }
return true; return true;
} }
void ITExecutiveMenu::searchEmployee()
{
std::string name;
std::cout << "Enter Employee Name: ";
util::read(name);
searchTheEmployee(name, m_zenvyController);
}
@@ -1,6 +1,5 @@
#pragma once #pragma once
#include<memory> #include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h" #include"ZenvyController.h"
class ITExecutiveMenu class ITExecutiveMenu
@@ -11,6 +10,5 @@ public:
ITExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; ITExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
void searchEmployee();
}; };
@@ -11,8 +11,12 @@
#include "ZenvyController.h" #include "ZenvyController.h"
#include "Payroll.h" #include "Payroll.h"
inline void searchTheEmployee(const std::string& name, 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); std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchResults = m_zenvyController->searchEmployee(name);
if (!(searchResults.second).empty()) if (!(searchResults.second).empty())
{ {
@@ -2,6 +2,7 @@
#include "TalentExecutiveMenu.h" #include "TalentExecutiveMenu.h"
#include"InputHelper.h" #include"InputHelper.h"
#include"OutputHelper.h" #include"OutputHelper.h"
#include "MenuHelper.h"
void TalentExecutiveMenu::run() void TalentExecutiveMenu::run()
{ {
@@ -44,7 +45,7 @@ bool TalentExecutiveMenu::handleOperation(int choice)
m_zenvyController.viewEmployees(); m_zenvyController.viewEmployees();
break;*/ break;*/
case 5: case 5:
searchEmployee(); searchEmployee(m_zenvyController);
break; break;
/*case 6: /*case 6:
m_zenvyController.viewNotifications(); m_zenvyController.viewNotifications();
@@ -74,11 +75,3 @@ bool TalentExecutiveMenu::handleOperation(int choice)
} }
return true; return true;
} }
void TalentExecutiveMenu::searchEmployee()
{
std::string name;
std::cout << "Enter Employee Name: ";
util::read(name);
searchTheEmployee(name, m_zenvyController);
}
@@ -1,6 +1,5 @@
#pragma once #pragma once
#include<memory> #include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h" #include"ZenvyController.h"
class TalentExecutiveMenu class TalentExecutiveMenu
@@ -11,6 +10,5 @@ public:
TalentExecutiveMenu() : m_zenvyController(std::make_shared < ZenvyController>()) {}; TalentExecutiveMenu() : m_zenvyController(std::make_shared < ZenvyController>()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
void searchEmployee();
}; };
@@ -2,6 +2,7 @@
#include "TeamExecutiveMenu.h" #include "TeamExecutiveMenu.h"
#include"InputHelper.h" #include"InputHelper.h"
#include"OutputHelper.h" #include"OutputHelper.h"
#include "MenuHelper.h"
void TeamExecutiveMenu::run() void TeamExecutiveMenu::run()
{ {
@@ -44,7 +45,7 @@ bool TeamExecutiveMenu::handleOperation(int choice)
m_zenvyController.viewEmployees(); m_zenvyController.viewEmployees();
break;*/ break;*/
case 5: case 5:
searchEmployee(); searchEmployee(m_zenvyController);
break; break;
/*case 6: /*case 6:
m_zenvyController.viewNotifications(); m_zenvyController.viewNotifications();
@@ -77,11 +78,3 @@ bool TeamExecutiveMenu::handleOperation(int choice)
} }
return true; return true;
} }
void TalentExecutiveMenu::searchEmployee()
{
std::string name;
std::cout << "Enter Employee Name: ";
util::read(name);
searchTheEmployee(name, m_zenvyController);
}
@@ -1,6 +1,5 @@
#pragma once #pragma once
#include<memory> #include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h" #include"ZenvyController.h"
class TeamExecutiveMenu class TeamExecutiveMenu
@@ -11,6 +10,5 @@ public:
TeamExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; TeamExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
void searchEmployee();
}; };
@@ -2,6 +2,7 @@
#include "TeamLeadMenu.h" #include "TeamLeadMenu.h"
#include"InputHelper.h" #include"InputHelper.h"
#include"OutputHelper.h" #include"OutputHelper.h"
#include "MenuHelper.h"
void TeamLeadMenu::run() void TeamLeadMenu::run()
{ {
@@ -53,7 +54,7 @@ bool TeamLeadMenu::handleOperation(int choice)
m_zenvyController.viewEmployees(); m_zenvyController.viewEmployees();
break;*/ break;*/
case 8: case 8:
searchEmployee(); searchEmployee(m_zenvyController);
break; break;
/*case 9: /*case 9:
m_zenvyController.viewTeamMembers(); m_zenvyController.viewTeamMembers();
@@ -83,11 +84,3 @@ bool TeamLeadMenu::handleOperation(int choice)
} }
return true; return true;
} }
void TeamLeadMenu::searchEmployee()
{
std::string name;
std::cout << "Enter Employee Name: ";
util::read(name);
searchTheEmployee(name, m_zenvyController);
}
@@ -1,6 +1,5 @@
#pragma once #pragma once
#include<memory> #include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h" #include"ZenvyController.h"
class TeamLeadMenu class TeamLeadMenu
@@ -11,6 +10,5 @@ public:
TeamLeadMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; TeamLeadMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
void searchEmployee();
}; };