From 974d4efe0227c22da598ae7515c992e15734aa34 Mon Sep 17 00:00:00 2001 From: Jissin Mathew Date: Wed, 17 Jun 2026 14:47:37 +0530 Subject: [PATCH] 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 --- .../Trenser.VehicleServiceSystem/datastores/DataStore.cpp | 2 +- .../services/ServiceManagementService.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.cpp index b77ad3d..2d0d153 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/datastores/DataStore.cpp @@ -415,7 +415,7 @@ util::Map>& DataStore::getJobCards() { throw std::runtime_error("Invalid booking ID: " + bookingId); } - auto trackedBooking = serviceBookings.getValueAt(bookingIndex); + auto& trackedBooking = serviceBookings.getValueAt(bookingIndex); jobCard->setBooking(trackedBooking.data); const std::string& serviceId = jobCard->getServiceId(); int serviceIndex = services.find(serviceId); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index cf438d0..2949778 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -72,6 +72,7 @@ void ServiceManagementService::purchaseService(const util::Vector& std::string title = "Service Booking succeeded"; std::string message = "Your service booking has been successfully placed with ID " + serviceBooking->getId(); 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 message = "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId(); sendNotification(authenticatedUser, title, message); + m_dataStore.saveServiceBookings(); } util::Map ServiceManagementService::m_observers{};