70e1ef66d4
<UserStory> SER003: Remove Service </UserStory>
<Changes>
1. Added integration between Controller and ServiceManagementService to support service removal.
2. Implemented ServiceManagementService::removeService with validation for service existence and marking as INACTIVE.
3. Enhanced Controller::getServices to return a read-only map of services for safe UI access.
4. Added AdminMenu::selectServicesToRemove helper to list active services in tabular format and capture user choice.
5. Updated AdminMenu::removeService to prompt for service selection, delegate removal to Controller, and display success/failure messages.
</Changes>
<Test>
Acceptance Criteria:
1. Admin selects service ID.
2. System confirms deletion.
3. Service removed from customer menu.
Precondition:
1. Admin is logged into the system.
2. At least one active service exists in the datastore.
3. Customer menu displays available services.
Steps:
1. Navigate to Admin menu and choose "Remove Service".
- Verify that the system lists active services in tabular format.
2. Select a service ID from the list.
- Verify that the system confirms deletion.
3. Check customer menu.
- Verify that the removed service no longer appears.
</Test>
<Review>
Sreeja Reghukumar, please review
</Review>
21 lines
545 B
C++
21 lines
545 B
C++
#include "ServiceManagementService.h"
|
|
#include "Service.h"
|
|
#include "Enums.h"
|
|
|
|
util::Map<std::string, Service*> ServiceManagementService::getServices()
|
|
{
|
|
return m_dataStore.getServices();
|
|
}
|
|
|
|
void ServiceManagementService::removeService(const std::string& serviceID)
|
|
{
|
|
util::Map<std::string, Service*> currentServices = getServices();
|
|
if (currentServices.find(serviceID) != -1)
|
|
{
|
|
currentServices.getValueAt(currentServices.find(serviceID))->setState(util::State::INACTIVE);
|
|
}
|
|
else
|
|
{
|
|
throw std::runtime_error("Service not found.");
|
|
}
|
|
} |