diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index f372bef..8f95e02 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -858,6 +858,7 @@ util::Map ServiceManagementService::getServiceBook DataStoreLockGuard lock(m_dataStore); util::Map serviceBookings; serviceBookings = util::getObjects(m_dataStore.getServiceBookings()); + return serviceBookings; } /* @@ -896,9 +897,9 @@ Throws: */ void ServiceManagementService::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID) { + DataStoreLockGuard lock(m_dataStore); UserManagementService m_userManagementService; ServiceBooking* currentBooking = getServiceBooking(bookingID); - DataStoreLockGuard lock(m_dataStore); auto& currentTrackedJobCards = m_dataStore.getJobCards(); if (currentBooking == nullptr) { @@ -955,6 +956,7 @@ void ServiceManagementService::createJobCard(const std::string& bookingID, const title = "Technician assigned"; message = "A technician has been assigned to your Service Booking with ID " + bookingID; sendNotification(currentBooking->getCustomer(), title, message); + m_dataStore.saveJobCards(); } /* @@ -972,9 +974,10 @@ Throws: */ void ServiceManagementService::createService(const std::string& name, const util::Vector& inventoryItemIDs, double laborCost) { - util::Map currentServiceInventoryItems; DataStoreLockGuard lock(m_dataStore); + util::Map currentServiceInventoryItems; auto& trackedInventoryItems = m_dataStore.getInventoryItems(); + auto& currentServices = m_dataStore.getServices(); for (int iteratorOne =0; iteratorOne < inventoryItemIDs.getSize(); iteratorOne++) { std::string currentItemID = inventoryItemIDs[iteratorOne]; @@ -999,12 +1002,12 @@ void ServiceManagementService::createService(const std::string& name, const util { throw std::runtime_error("Unable to create new service."); } - auto& currentServices = m_dataStore.getServices(); if (currentServices.find(newService->getId()) != -1) { throw std::runtime_error("Service with this ID Already exists."); } currentServices.insert(newService->getId(), util::createNewRecord(newService)); + m_dataStore.saveServices(); } /*