Implement review fixes

This commit is contained in:
Jissin Mathew
2026-06-15 14:52:19 +05:30
parent f3220ee191
commit e1676568cd
@@ -858,6 +858,7 @@ util::Map<std::string, ServiceBooking*> ServiceManagementService::getServiceBook
DataStoreLockGuard lock(m_dataStore); DataStoreLockGuard lock(m_dataStore);
util::Map<std::string, ServiceBooking*> serviceBookings; util::Map<std::string, ServiceBooking*> serviceBookings;
serviceBookings = util::getObjects(m_dataStore.getServiceBookings()); 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) void ServiceManagementService::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID)
{ {
DataStoreLockGuard lock(m_dataStore);
UserManagementService m_userManagementService; UserManagementService m_userManagementService;
ServiceBooking* currentBooking = getServiceBooking(bookingID); ServiceBooking* currentBooking = getServiceBooking(bookingID);
DataStoreLockGuard lock(m_dataStore);
auto& currentTrackedJobCards = m_dataStore.getJobCards(); auto& currentTrackedJobCards = m_dataStore.getJobCards();
if (currentBooking == nullptr) if (currentBooking == nullptr)
{ {
@@ -955,6 +956,7 @@ void ServiceManagementService::createJobCard(const std::string& bookingID, const
title = "Technician assigned"; title = "Technician assigned";
message = "A technician has been assigned to your Service Booking with ID " + bookingID; message = "A technician has been assigned to your Service Booking with ID " + bookingID;
sendNotification(currentBooking->getCustomer(), title, message); sendNotification(currentBooking->getCustomer(), title, message);
m_dataStore.saveJobCards();
} }
/* /*
@@ -972,9 +974,10 @@ Throws:
*/ */
void ServiceManagementService::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost) void ServiceManagementService::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost)
{ {
util::Map<std::string, InventoryItem*> currentServiceInventoryItems;
DataStoreLockGuard lock(m_dataStore); DataStoreLockGuard lock(m_dataStore);
util::Map<std::string, InventoryItem*> currentServiceInventoryItems;
auto& trackedInventoryItems = m_dataStore.getInventoryItems(); auto& trackedInventoryItems = m_dataStore.getInventoryItems();
auto& currentServices = m_dataStore.getServices();
for (int iteratorOne =0; iteratorOne < inventoryItemIDs.getSize(); iteratorOne++) for (int iteratorOne =0; iteratorOne < inventoryItemIDs.getSize(); iteratorOne++)
{ {
std::string currentItemID = inventoryItemIDs[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."); throw std::runtime_error("Unable to create new service.");
} }
auto& currentServices = m_dataStore.getServices();
if (currentServices.find(newService->getId()) != -1) if (currentServices.find(newService->getId()) != -1)
{ {
throw std::runtime_error("Service with this ID Already exists."); throw std::runtime_error("Service with this ID Already exists.");
} }
currentServices.insert(newService->getId(), util::createNewRecord(newService)); currentServices.insert(newService->getId(), util::createNewRecord(newService));
m_dataStore.saveServices();
} }
/* /*