Fix Service Removal and Combo Package Management Issues
- Added ComboPackage dependency check in removeService; deactivates related packages when a service is removed. - Added filterActiveServices helper to list only active services. - Updated removeService and removeComboPackage with headings, empty-state checks, and consistent success/error messages. - Enhanced createComboPackages: - Uses active services only. - Added cancel option and confirmation after first selection. - Prevented duplicate selection and infinite loop when limited services exist. - Improved feedback when all available services are selected. - Updated selectServicesToRemove and selectComboPackage to handle empty states gracefully without exceptions. Fixes #1749
This commit is contained in:
+19
@@ -26,6 +26,7 @@ Date:19-May-2026
|
||||
#include "User.h"
|
||||
#include "UserManagementService.h"
|
||||
#include "Utility.h"
|
||||
#include "ComboPackage.h"
|
||||
|
||||
/*
|
||||
Function: purchaseService
|
||||
@@ -909,9 +910,27 @@ Throws:
|
||||
void ServiceManagementService::removeService(const std::string& serviceID)
|
||||
{
|
||||
util::Map<std::string, Service*>& currentServices = m_dataStore.getServices();
|
||||
util::Map<std::string, ComboPackage*>& currentComboPackages = m_dataStore.getComboPackages();
|
||||
if (currentServices.find(serviceID) != -1)
|
||||
{
|
||||
currentServices.getValueAt(currentServices.find(serviceID))->setState(util::State::INACTIVE);
|
||||
for (int iterator = 0; iterator < currentComboPackages.getSize(); iterator++)
|
||||
{
|
||||
ComboPackage* currentComboPackage = currentComboPackages.getValueAt(iterator);
|
||||
if (currentComboPackage && currentComboPackage->getState() == util::State::ACTIVE)
|
||||
{
|
||||
util::Map<std::string, Service*> currentServices = currentComboPackage->getServices();
|
||||
for (int iterator = 0; iterator < currentServices.getSize(); iterator++)
|
||||
{
|
||||
auto currentService = currentServices.getValueAt(iterator);
|
||||
if (currentService->getId() == serviceID)
|
||||
{
|
||||
currentComboPackage->setState(util::State::INACTIVE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user