Notify admins when new service bookings are created
Changes: - Added notifyAllAdmins() helper in ServiceManagementService. - Sent notifications to all administrators when a customer places a service booking. - Sent notifications to all administrators when a customer purchases a combo package. - Included the generated Service Booking ID in admin notifications. Fixes #2100
This commit is contained in:
+27
@@ -29,6 +29,31 @@ Date:19-May-2026
|
|||||||
#include "DataStoreLockGuard.h"
|
#include "DataStoreLockGuard.h"
|
||||||
#include "EventManager.h"
|
#include "EventManager.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: notifyAllAdmins
|
||||||
|
Description: Sends a notification to all users with the ADMIN role.
|
||||||
|
Iterates through the provided user collection and delivers
|
||||||
|
the specified notification to each administrator using the
|
||||||
|
ServiceManagementService notification mechanism.
|
||||||
|
Parameter: const std::string& title - notification title
|
||||||
|
Parameter: const std::string& message - notification message
|
||||||
|
Parameter: const util::Map<std::string, TrackedRecord<User>>& users - collection of tracked users
|
||||||
|
Parameter: ServiceManagementService* serviceManagementService - service used to dispatch notifications
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
|
static void notifyAllAdmins(const std::string& title, const std::string& message, const util::Map<std::string, TrackedRecord<User>>& users, ServiceManagementService* serviceManagementService)
|
||||||
|
{
|
||||||
|
int numberOfUsers = users.getSize();
|
||||||
|
for (int index = 0; index < numberOfUsers; index++)
|
||||||
|
{
|
||||||
|
User* user = users.getValueAt(index).data;
|
||||||
|
if (user->getUserType() == util::UserType::ADMIN)
|
||||||
|
{
|
||||||
|
serviceManagementService->sendNotification(user, title, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: purchaseService
|
Function: purchaseService
|
||||||
Description: Creates a new service booking for the authenticated user. Validates
|
Description: Creates a new service booking for the authenticated user. Validates
|
||||||
@@ -73,6 +98,7 @@ void ServiceManagementService::purchaseService(const util::Vector<std::string>&
|
|||||||
std::string title = "Service Booking succeeded";
|
std::string title = "Service Booking succeeded";
|
||||||
std::string message = "Your service booking has been successfully placed with ID " + serviceBooking->getId();
|
std::string message = "Your service booking has been successfully placed with ID " + serviceBooking->getId();
|
||||||
sendNotification(authenticatedUser, title, message);
|
sendNotification(authenticatedUser, title, message);
|
||||||
|
notifyAllAdmins("New Service Order Available", "A new service order has been placed with Service Booking ID " + serviceBooking->getId(), m_dataStore.getUsers(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -114,6 +140,7 @@ void ServiceManagementService::purchaseComboPackage(const std::string& comboPack
|
|||||||
std::string title = "Combo Package Service Booking succeeded";
|
std::string title = "Combo Package Service Booking succeeded";
|
||||||
std::string message = "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId();
|
std::string message = "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId();
|
||||||
sendNotification(authenticatedUser, title, message);
|
sendNotification(authenticatedUser, title, message);
|
||||||
|
notifyAllAdmins("New Combo Package Order Available", "A new combo package order has been placed with Service Booking ID " + serviceBooking->getId(), m_dataStore.getUsers(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
util::Map<std::string, User*> ServiceManagementService::m_observers{};
|
util::Map<std::string, User*> ServiceManagementService::m_observers{};
|
||||||
|
|||||||
Reference in New Issue
Block a user