Update Update Designation functionality based on review
<UserStory> EMP005 : Update Designation </UserStory> <Changes> - Refactor GeneralEmployee constructors clean. - update Designation logic. - Improve menu display messages. </Changes> <Review> Smitha Mohan </Review>
This commit is contained in:
@@ -8,8 +8,7 @@ private:
|
|||||||
Enums::EmployeeDesignation m_designation;
|
Enums::EmployeeDesignation m_designation;
|
||||||
public:
|
public:
|
||||||
GeneralEmployee()
|
GeneralEmployee()
|
||||||
: m_designation(Enums::EmployeeDesignation::JUNIOR) {
|
: m_designation(Enums::EmployeeDesignation::JUNIOR) {}
|
||||||
}
|
|
||||||
GeneralEmployee(const std::string& name,
|
GeneralEmployee(const std::string& name,
|
||||||
const std::string& phone,
|
const std::string& phone,
|
||||||
const std::string& email,
|
const std::string& email,
|
||||||
@@ -20,8 +19,7 @@ public:
|
|||||||
email,
|
email,
|
||||||
Enums::EmployeeType::GENERAL,
|
Enums::EmployeeType::GENERAL,
|
||||||
payroll),
|
payroll),
|
||||||
m_designation(designation) {
|
m_designation(designation) {}
|
||||||
}
|
|
||||||
GeneralEmployee(const std::string& id,
|
GeneralEmployee(const std::string& id,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::string& phone,
|
const std::string& phone,
|
||||||
@@ -40,8 +38,7 @@ public:
|
|||||||
teamStatus,
|
teamStatus,
|
||||||
Enums::EmployeeType::GENERAL,
|
Enums::EmployeeType::GENERAL,
|
||||||
accountStatus),
|
accountStatus),
|
||||||
m_designation(employeeDesignation) {
|
m_designation(employeeDesignation) {}
|
||||||
}
|
|
||||||
Enums::EmployeeDesignation getDesignation() const;
|
Enums::EmployeeDesignation getDesignation() const;
|
||||||
void setDesignation(Enums::EmployeeDesignation designation);
|
void setDesignation(Enums::EmployeeDesignation designation);
|
||||||
std::string serialize() const override;
|
std::string serialize() const override;
|
||||||
|
|||||||
@@ -135,13 +135,13 @@ bool EmployeeManagementService::updateDesignation(const std::string& id, Enums::
|
|||||||
{
|
{
|
||||||
auto& authenticatedEmployee = m_dataStore.getAuthenticatedEmployee();
|
auto& authenticatedEmployee = m_dataStore.getAuthenticatedEmployee();
|
||||||
util::enforceAuthorization(authenticatedEmployee->getEmployeeType(), Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR);
|
util::enforceAuthorization(authenticatedEmployee->getEmployeeType(), Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR);
|
||||||
std::map<std::string, std::shared_ptr<Employee>> employee = m_dataStore.getEmployees();
|
std::map<std::string, std::shared_ptr<Employee>> employees = m_dataStore.getEmployees();
|
||||||
auto iterator = employee.find(id);
|
auto employeeIterator = employees.find(id);
|
||||||
if (iterator == employee.end())
|
if (employeeIterator == employees.end())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>((*iterator).second);
|
auto generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>((*employeeIterator).second);
|
||||||
if (generalEmployee)
|
if (generalEmployee)
|
||||||
{
|
{
|
||||||
generalEmployee->setDesignation(designation);
|
generalEmployee->setDesignation(designation);
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ void createEmployee(std::shared_ptr<ZenvyController> controller)
|
|||||||
Enums::EmployeeDesignation designation = getEmployeeDesignation();
|
Enums::EmployeeDesignation designation = getEmployeeDesignation();
|
||||||
if (m_zenvyController->updateDesignation(selectedEmployeeId, designation))
|
if (m_zenvyController->updateDesignation(selectedEmployeeId, designation))
|
||||||
{
|
{
|
||||||
std::cout << "Assign Employee Role successfull\n";
|
std::cout << "Assigned Employee Role Successfully\n";
|
||||||
util::pressEnter();
|
util::pressEnter();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -140,23 +140,20 @@ inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>>
|
|||||||
for (const auto& employee : employeeList)
|
for (const auto& employee : employeeList)
|
||||||
{
|
{
|
||||||
auto generalEmployee = std::dynamic_pointer_cast<const GeneralEmployee>(employee.second);
|
auto generalEmployee = std::dynamic_pointer_cast<const GeneralEmployee>(employee.second);
|
||||||
|
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());
|
||||||
if (generalEmployee)
|
if (generalEmployee)
|
||||||
{
|
{
|
||||||
std::cout << std::left
|
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::setw(20) << Enums::getEmployeeDesignationString(generalEmployee->getDesignation())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << std::left
|
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::setw(20) << "NULL"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
@@ -297,4 +294,3 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
|||||||
}
|
}
|
||||||
util::pressEnter();
|
util::pressEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user