Fix Service Booking Creation Is Not Synchronized Between Processes
Changes: - Updated ServiceManagementService::purchaseService() to persist service bookings immediately after creation using m_dataStore.saveServiceBookings(). - Updated ServiceManagementService::purchaseComboPackage() to persist combo package bookings immediately after creation using m_dataStore.saveServiceBookings(). - Changed DataStore::getJobCards() to use a reference for tracked bookings to ensure consistent linkage and prevent overwriting. Fixes #2074
This commit is contained in:
@@ -415,7 +415,7 @@ util::Map<std::string, TrackedRecord<JobCard>>& DataStore::getJobCards()
|
|||||||
{
|
{
|
||||||
throw std::runtime_error("Invalid booking ID: " + bookingId);
|
throw std::runtime_error("Invalid booking ID: " + bookingId);
|
||||||
}
|
}
|
||||||
auto trackedBooking = serviceBookings.getValueAt(bookingIndex);
|
auto& trackedBooking = serviceBookings.getValueAt(bookingIndex);
|
||||||
jobCard->setBooking(trackedBooking.data);
|
jobCard->setBooking(trackedBooking.data);
|
||||||
const std::string& serviceId = jobCard->getServiceId();
|
const std::string& serviceId = jobCard->getServiceId();
|
||||||
int serviceIndex = services.find(serviceId);
|
int serviceIndex = services.find(serviceId);
|
||||||
|
|||||||
+2
@@ -72,6 +72,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);
|
||||||
|
m_dataStore.saveServiceBookings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -112,6 +113,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);
|
||||||
|
m_dataStore.saveServiceBookings();
|
||||||
}
|
}
|
||||||
|
|
||||||
util::Map<std::string, User*> ServiceManagementService::m_observers{};
|
util::Map<std::string, User*> ServiceManagementService::m_observers{};
|
||||||
|
|||||||
Reference in New Issue
Block a user