Implement Remove Combo Package for admin
<UserStory> SER003: Remove Combo Package </UserStory> <Changes> Added integration between Controller and ServiceManagementService to support combo package removal. Implemented ServiceManagementService::removeComboPackage with validation for package ID and marking state as INACTIVE. Enhanced AdminMenu with displayComboPackagesWithIndex helper to show packages in tabular format with index. Updated AdminMenu::selectComboPackage to allow selection of active packages only and return selected package ID. Updated AdminMenu::removeComboPackage to prompt for selection, confirm removal, and provide success/failure feedback. </Changes> <Test> Acceptance Criteria: Admin selects package ID. System confirms deletion. Package removed from customer menu. Precondition: Admin is logged into the system. At least one active combo package exists. Datastore is available for storing combo packages. Steps: Navigate to Admin menu and choose "Remove Combo Package". Verify that the system displays available active packages in tabular format with index. Select a package ID from the list. Verify that inactive packages are skipped and only active ones are selectable. Confirm removal. Verify that the package is marked INACTIVE and removed from customer menu. Check customer view. Verify that the removed package is no longer visible to customers. </Test> <Review> Sreeja Reghukumar, please review </Review>
This commit is contained in:
+27
@@ -1 +1,28 @@
|
||||
#include "ServiceManagementService.h"
|
||||
#include "ComboPackage.h"
|
||||
#include "Enums.h"
|
||||
|
||||
util::Map<std::string, ComboPackage*> ServiceManagementService::getComboPackages()
|
||||
{
|
||||
return m_dataStore.getComboPackages();
|
||||
}
|
||||
|
||||
void ServiceManagementService::removeComboPackage(const std::string& comboPackageID)
|
||||
{
|
||||
bool removed = false;
|
||||
util::Map<std::string, ComboPackage*>& currentComboPackages = m_dataStore.getComboPackages();
|
||||
for (int iterator = 0; iterator < currentComboPackages.getSize(); iterator++)
|
||||
{
|
||||
ComboPackage* currentComboPackage = currentComboPackages.getValueAt(iterator);
|
||||
if (currentComboPackage && currentComboPackage->getId() == comboPackageID)
|
||||
{
|
||||
currentComboPackage->setState(util::State::INACTIVE);
|
||||
removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!removed)
|
||||
{
|
||||
throw std::runtime_error("Combo package with ID '" + comboPackageID + "' not found.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user