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;
|
||||
public:
|
||||
GeneralEmployee()
|
||||
: m_designation(Enums::EmployeeDesignation::JUNIOR) {
|
||||
}
|
||||
: m_designation(Enums::EmployeeDesignation::JUNIOR) {}
|
||||
GeneralEmployee(const std::string& name,
|
||||
const std::string& phone,
|
||||
const std::string& email,
|
||||
@@ -20,8 +19,7 @@ public:
|
||||
email,
|
||||
Enums::EmployeeType::GENERAL,
|
||||
payroll),
|
||||
m_designation(designation) {
|
||||
}
|
||||
m_designation(designation) {}
|
||||
GeneralEmployee(const std::string& id,
|
||||
const std::string& name,
|
||||
const std::string& phone,
|
||||
@@ -40,8 +38,7 @@ public:
|
||||
teamStatus,
|
||||
Enums::EmployeeType::GENERAL,
|
||||
accountStatus),
|
||||
m_designation(employeeDesignation) {
|
||||
}
|
||||
m_designation(employeeDesignation) {}
|
||||
Enums::EmployeeDesignation getDesignation() const;
|
||||
void setDesignation(Enums::EmployeeDesignation designation);
|
||||
std::string serialize() const override;
|
||||
|
||||
@@ -135,13 +135,13 @@ bool EmployeeManagementService::updateDesignation(const std::string& id, Enums::
|
||||
{
|
||||
auto& authenticatedEmployee = m_dataStore.getAuthenticatedEmployee();
|
||||
util::enforceAuthorization(authenticatedEmployee->getEmployeeType(), Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR);
|
||||
std::map<std::string, std::shared_ptr<Employee>> employee = m_dataStore.getEmployees();
|
||||
auto iterator = employee.find(id);
|
||||
if (iterator == employee.end())
|
||||
std::map<std::string, std::shared_ptr<Employee>> employees = m_dataStore.getEmployees();
|
||||
auto employeeIterator = employees.find(id);
|
||||
if (employeeIterator == employees.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>((*iterator).second);
|
||||
auto generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>((*employeeIterator).second);
|
||||
if (generalEmployee)
|
||||
{
|
||||
generalEmployee->setDesignation(designation);
|
||||
|
||||
@@ -113,7 +113,7 @@ void createEmployee(std::shared_ptr<ZenvyController> controller)
|
||||
Enums::EmployeeDesignation designation = getEmployeeDesignation();
|
||||
if (m_zenvyController->updateDesignation(selectedEmployeeId, designation))
|
||||
{
|
||||
std::cout << "Assign Employee Role successfull\n";
|
||||
std::cout << "Assigned Employee Role Successfully\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -140,23 +140,20 @@ inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>>
|
||||
for (const auto& employee : employeeList)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
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::endl;
|
||||
}
|
||||
@@ -296,5 +293,4 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
|
||||
std::cout << "No Employee found with this name" << std::endl;
|
||||
}
|
||||
util::pressEnter();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user