45d4f693b6
Changes: - Added missing include for MenuHelper.h in project and AdminMenu - Fixed typo in variable name inventoryIems to inventoryItems in Controller.cpp - Removed stray semicolon from include in Controller.h - Cleaned up duplicate comments in Controller.cpp description header - Minor formatting adjustments with blank lines after headers in multiple files - Updated ServiceManagementService notification message to remove informal wording - Refactored AdminMenu::changePassword to use changePasswordHelper - Added util::clear() call at start of viewStockLevels - Removed redundant helper functions from AdminMenu.cpp and moved to shared helpers - Fixed bug in removeInventoryItem to use activeItems instead of inventoryItems - Enhanced createComboPackages to enforce selection of two distinct services - General comment cleanup and formatting consistency across headers and implementation files
56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
/*
|
|
File: UserManagementService.cpp
|
|
Description: Implementation file containing the method definitions of the
|
|
UserManagementService class, including user retrieval and removal logic.
|
|
Author: Trenser
|
|
Date:19-May-2026
|
|
*/
|
|
|
|
#include "UserManagementService.h"
|
|
#include "User.h"
|
|
|
|
/*
|
|
Function: getUsers
|
|
Description: Retrieves all users stored in the DataStore.
|
|
Parameter: None
|
|
Return type: util::Map<std::string, User*>
|
|
*/
|
|
util::Map<std::string, User*> UserManagementService::getUsers()
|
|
{
|
|
return m_dataStore.getUsers();
|
|
}
|
|
|
|
/*
|
|
Function: getUser
|
|
Description: Retrieves a specific user by ID from the DataStore.
|
|
Parameter: const std::string& userID - ID of the user
|
|
Return type: User*
|
|
*/
|
|
User* UserManagementService::getUser(const std::string& userID)
|
|
{
|
|
int index = m_dataStore.getUsers().find(userID);
|
|
if (index != -1)
|
|
{
|
|
return m_dataStore.getUsers().getValueAt(index);
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
/*
|
|
Function: removeUser
|
|
Description: Marks a user as inactive in the DataStore instead of deleting them.
|
|
Parameter: const std::string& userID - ID of the user to remove
|
|
Return type: void
|
|
*/
|
|
void UserManagementService::removeUser(const std::string& userID)
|
|
{
|
|
int index = m_dataStore.getUsers().find(userID);
|
|
if (index != -1)
|
|
{
|
|
User* user = m_dataStore.getUsers().getValueAt(index);
|
|
if (user != nullptr)
|
|
{
|
|
user->setState(util::State::INACTIVE);
|
|
}
|
|
}
|
|
} |