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
@@ -45,7 +45,7 @@ bool AdminMenu::handleOperation(int choice)
m_zenvyController.deactivateEmployee();
break;*/
case 5:
searchEmployee();
searchEmployee(m_zenvyController);
break;
case 6:
return false;
@@ -55,10 +55,3 @@ bool AdminMenu::handleOperation(int choice)
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
#include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h"
class AdminMenu
@@ -11,6 +10,5 @@ public:
AdminMenu() :m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
void searchEmployee();
};
@@ -2,6 +2,7 @@
#include "EmployeeMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
#include "MenuHelper.h"
void EmployeeMenu::run()
{
@@ -53,7 +54,7 @@ bool EmployeeMenu::handleOperation(int choice)
m_zenvyController.viewEmployees();
break;*/
case 8:
searchEmployee();
searchEmployee(m_zenvyController);
break;
/*case 9:
m_zenvyController.viewTeamMembers();
@@ -77,10 +78,4 @@ bool EmployeeMenu::handleOperation(int choice)
}
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
#include<memory>
#include <iomanip>
#include "MenuHelper.h"
#include"ZenvyController.h"
class EmployeeMenu
@@ -12,6 +10,5 @@ public:
EmployeeMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
void searchEmployee();
};
@@ -2,6 +2,7 @@
#include "FinanceExecutiveMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
#include "MenuHelper.h"
void FinanceExecutiveMenu::run()
{
@@ -44,7 +45,7 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
m_zenvyController.viewEmployees();
break;*/
case 5:
searchEmployee();
searchEmployee(m_zenvyController);
break;
/*case 6:
m_zenvyController.viewNotifications();
@@ -68,11 +69,3 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
}
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
#include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h"
class FinanceExecutiveMenu
@@ -11,6 +10,5 @@ public:
FinanceExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
void searchEmployee();
};
@@ -2,6 +2,7 @@
#include "HRManagerMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
#include "MenuHelper.h"
void HRManagerMenu::run()
{
@@ -44,7 +45,7 @@ bool HRManagerMenu::handleOperation(int choice)
m_zenvyController.viewEmployees();
break;*/
case 5:
searchEmployee();
searchEmployee(m_zenvyController);
break;
/*case 6:
m_zenvyController.viewNotifications();
@@ -71,11 +72,3 @@ bool HRManagerMenu::handleOperation(int choice)
}
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
#include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h"
class HRManagerMenu
@@ -11,6 +10,5 @@ public:
HRManagerMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
void searchEmployee();
};
@@ -2,6 +2,7 @@
#include "ITExecutiveMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
#include "MenuHelper.h"
void ITExecutiveMenu::run()
{
@@ -44,7 +45,7 @@ bool ITExecutiveMenu::handleOperation(int choice)
m_zenvyController.viewEmployees();
break;*/
case 5:
searchEmployee();
searchEmployee(m_zenvyController);
break;
/*case 6:
m_zenvyController.viewNotifications();
@@ -62,11 +63,3 @@ bool ITExecutiveMenu::handleOperation(int choice)
}
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
#include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h"
class ITExecutiveMenu
@@ -11,6 +10,5 @@ public:
ITExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
void searchEmployee();
};
@@ -11,8 +11,12 @@
#include "ZenvyController.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);
if (!(searchResults.second).empty())
{
@@ -2,6 +2,7 @@
#include "TalentExecutiveMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
#include "MenuHelper.h"
void TalentExecutiveMenu::run()
{
@@ -44,7 +45,7 @@ bool TalentExecutiveMenu::handleOperation(int choice)
m_zenvyController.viewEmployees();
break;*/
case 5:
searchEmployee();
searchEmployee(m_zenvyController);
break;
/*case 6:
m_zenvyController.viewNotifications();
@@ -73,12 +74,4 @@ bool TalentExecutiveMenu::handleOperation(int choice)
std::cout << "Enter a valid choice!" << std::endl;*/
}
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
#include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h"
class TalentExecutiveMenu
@@ -11,6 +10,5 @@ public:
TalentExecutiveMenu() : m_zenvyController(std::make_shared < ZenvyController>()) {};
void run();
bool handleOperation(int);
void searchEmployee();
};
@@ -2,6 +2,7 @@
#include "TeamExecutiveMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
#include "MenuHelper.h"
void TeamExecutiveMenu::run()
{
@@ -44,7 +45,7 @@ bool TeamExecutiveMenu::handleOperation(int choice)
m_zenvyController.viewEmployees();
break;*/
case 5:
searchEmployee();
searchEmployee(m_zenvyController);
break;
/*case 6:
m_zenvyController.viewNotifications();
@@ -76,12 +77,4 @@ bool TeamExecutiveMenu::handleOperation(int choice)
std::cout << "Enter a valid choice!" << std::endl;*/
}
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
#include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h"
class TeamExecutiveMenu
@@ -11,6 +10,5 @@ public:
TeamExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
void searchEmployee();
};
@@ -2,6 +2,7 @@
#include "TeamLeadMenu.h"
#include"InputHelper.h"
#include"OutputHelper.h"
#include "MenuHelper.h"
void TeamLeadMenu::run()
{
@@ -53,7 +54,7 @@ bool TeamLeadMenu::handleOperation(int choice)
m_zenvyController.viewEmployees();
break;*/
case 8:
searchEmployee();
searchEmployee(m_zenvyController);
break;
/*case 9:
m_zenvyController.viewTeamMembers();
@@ -82,12 +83,4 @@ bool TeamLeadMenu::handleOperation(int choice)
std::cout << "Enter a valid choice!" << std::endl;*/
}
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
#include<memory>
#include "MenuHelper.h"
#include"ZenvyController.h"
class TeamLeadMenu
@@ -11,6 +10,5 @@ public:
TeamLeadMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
void run();
bool handleOperation(int);
void searchEmployee();
};