Implement employee creation
<UserStory>EMP001 Create Employee</UserStory> <Changes> - Updated employee creation flow to support different employee types and designations - Set a default initial password for new employees - Added basic authorization check utility - Cleaned up employee model constructors for better consistency Minor code cleanup and refactoring </Changes> <Review> Smitha Mohan </Review>
This commit is contained in:
@@ -3,6 +3,87 @@
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.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;
|
||||
@@ -12,7 +93,7 @@ void AdminMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Zenvy - HR Management System\n1. Create HRManager\n2. Create Employee\n3. View Employee\n4. Deactivate Employee\n5. Logout\nEnter your Choice: ";
|
||||
std::cout << "Admin Menu\n1. Create User\n2. View Employee\n3. Deactivate Employee\n4. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -31,22 +112,19 @@ bool AdminMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
/*case 1:
|
||||
m_zenvyController.createHRManager();
|
||||
case 1:
|
||||
createEmployee(m_zenvyController);
|
||||
break;
|
||||
case 2:
|
||||
m_zenvyController.createEmployee();
|
||||
break;
|
||||
case 3:
|
||||
/*case 2:
|
||||
m_zenvyController.viewEmployee();
|
||||
break;
|
||||
case 4:
|
||||
case 3:
|
||||
m_zenvyController.deactivateEmployee();
|
||||
break;*/
|
||||
case 5:
|
||||
case 4:
|
||||
return false;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,84 @@
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.h"
|
||||
|
||||
static Enums::EmployeeType getEmployeeType()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Select Employee Type"
|
||||
"\n1. IT Executive"
|
||||
"\n2. Team Executive"
|
||||
"\n3. Finance Executive"
|
||||
"\n4. Talent Executive"
|
||||
"\n5. General Employee";
|
||||
util::read(choice);
|
||||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
return Enums::EmployeeType::IT;
|
||||
case 2:
|
||||
return Enums::EmployeeType::TEAM;
|
||||
case 3:
|
||||
return Enums::EmployeeType::FINANCE;
|
||||
case 4:
|
||||
return Enums::EmployeeType::TAG;
|
||||
case 5:
|
||||
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 HRManagerMenu::run()
|
||||
{
|
||||
bool isMenuActive = true;
|
||||
@@ -52,9 +130,9 @@ bool HRManagerMenu::handleOperation(int choice)
|
||||
//case 7:
|
||||
// m_zenvyController.viewAnnouncements();
|
||||
// break;
|
||||
//case 8:
|
||||
// m_zenvyController.createEmployee();
|
||||
// break;
|
||||
case 8:
|
||||
createEmployee(m_zenvyController);
|
||||
break;
|
||||
//case 9:
|
||||
// m_zenvyController.regularizeAttenance();
|
||||
// break;
|
||||
|
||||
Reference in New Issue
Block a user