Implement Review Suggestion

<UserStory>EMP008: Update Salary Details</UserStory>

    <Changes>
  - Refactored salary update and employee selection:
  • Removed unnecessary const qualifiers from double parameters
  • Renamed variables
  • Replaced count() with find() for map lookups
  • Excluded ADMIN employees from salary updates and selection lists
  • Applied util::enforceAuthorization for access control
- Improved readability and consistency:
  • Enhanced tabular output using setw() with left alignment
    Implement Update Salary
    </Changes>

    <Review>
    Smitha Mohan
    </Review>
This commit is contained in:
Jissin Sam Mathew
2026-04-07 20:19:27 +05:30
committed by Joel Thomas
parent 63627075ef
commit 0290467528
7 changed files with 47 additions and 35 deletions
@@ -31,28 +31,39 @@ void FinanceExecutiveMenu::run()
std::string FinanceExecutiveMenu::getSelectedUserId()
{
int choice;
std::map<int, std::shared_ptr<const Employee>> currentEmployeeList;
std::map<int, std::shared_ptr<const Employee>> employeeList;
int index = 0;
for (auto& currentEmployee : m_zenvyController->getEmployees())
auto allEmployees = m_zenvyController->getEmployees();
for (auto& currentEmployee : allEmployees)
{
currentEmployeeList[++index] = currentEmployee;
if (currentEmployee->getEmployeeType() == Enums::EmployeeType::ADMIN)
{
continue;
}
employeeList[++index] = currentEmployee;
}
for (auto& currentEmployee: currentEmployeeList)
std::cout << std::left
<< std::setw(6) << "Index"
<< std::setw(15) << "Employee Id"
<< std::setw(25) << "Name" << std::endl;
for (const auto& employee : employeeList)
{
std::cout << currentEmployee.first << ". Employee Id: " << currentEmployee.second->getEmployeeId() << "Name: " << currentEmployee.second->getEmployeeName() << std::endl;
std::cout << std::left << std::setw(6) << employee.first
<< std::setw(15) << employee.second->getEmployeeId()
<< std::setw(25) << employee.second->getEmployeeName()
<< std::endl;
}
std::cout << "Enter the Index: ";
util::read(choice);
if (currentEmployeeList.count(choice) == 0)
auto employeeIterator = employeeList.find(choice);
if (employeeIterator != employeeList.end())
{
throw std::runtime_error("Enter a valid index");
return (employeeIterator->second->getEmployeeId());
}
else
else
{
auto selectedEmployee = currentEmployeeList.find(choice);
return (selectedEmployee->second->getEmployeeId());
throw std::runtime_error("Invalid Index");
}
}
void FinanceExecutiveMenu::updatePayroll()
@@ -78,7 +89,6 @@ void FinanceExecutiveMenu::updatePayroll()
}
}
bool FinanceExecutiveMenu::handleOperation(int choice)
{
switch (choice)
@@ -1,6 +1,8 @@
#pragma once
#include<memory>
#include<iostream>
#include<stdexcept>
#include <iomanip>
#include"ZenvyController.h"
class FinanceExecutiveMenu