Merge branch 'feature-customer-management-cus007' into feature-customer-management
This commit is contained in:
+29
@@ -3,6 +3,7 @@
|
||||
#include "AuthenticationManagementService.h"
|
||||
#include "Service.h"
|
||||
#include "ServiceBooking.h"
|
||||
#include "ComboPackage.h"
|
||||
#include "Factory.h"
|
||||
|
||||
void ServiceManagementService::purchaseService(const util::Vector<std::string>& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
|
||||
@@ -37,3 +38,31 @@ void ServiceManagementService::purchaseService(const util::Vector<std::string>&
|
||||
"Service Booking succeeded",
|
||||
"Your service booking has been successfully placed with ID " + serviceBooking->getId());
|
||||
}
|
||||
|
||||
void ServiceManagementService::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
|
||||
{
|
||||
AuthenticationManagementService m_authenticationManagementService;
|
||||
auto authenticatedUser = m_authenticationManagementService.getAuthenticatedUser();
|
||||
if (authenticatedUser == nullptr)
|
||||
{
|
||||
throw std::runtime_error("No user is currently logged in!");
|
||||
}
|
||||
auto& comboPackagesMap = m_dataStore.getComboPackages();
|
||||
auto& serviceBookingMap = m_dataStore.getServiceBookings();
|
||||
int comboPackageIndex = comboPackagesMap.find(comboPackageID);
|
||||
if (comboPackageIndex == -1)
|
||||
{
|
||||
throw std::runtime_error("Combo Package not found!");
|
||||
}
|
||||
const ComboPackage* comboPackage = comboPackagesMap[comboPackageID];
|
||||
util::Map<std::string, Service*> selectedServices = comboPackage->getServices();
|
||||
ServiceBooking* serviceBooking = Factory::getObject<ServiceBooking>(util::ServiceJobStatus::STARTED, selectedServices, authenticatedUser->getId(), authenticatedUser, vehicleNumber, vehicleBrand, vehicleModel, comboPackage->getDiscountPercentage());
|
||||
if (serviceBooking == nullptr)
|
||||
{
|
||||
throw std::runtime_error("Failed to create combo package service booking");
|
||||
}
|
||||
serviceBookingMap[serviceBooking->getId()] = serviceBooking;
|
||||
sendNotification(authenticatedUser,
|
||||
"Combo Package Service Booking succeeded",
|
||||
"Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user