204 lines
6.7 KiB
C++
204 lines
6.7 KiB
C++
#include <stdexcept>
|
|
#include "Controller.h"
|
|
#include "InventoryItem.h"
|
|
#include "Service.h"
|
|
#include "ServiceBooking.h"
|
|
#include "JobCard.h"
|
|
#include "Enums.h"
|
|
#include "User.h"
|
|
|
|
bool Controller::login(const std::string& username, const std::string& password)
|
|
{
|
|
return m_authenticationManagementService.login(username, password);
|
|
}
|
|
|
|
void Controller::logout()
|
|
{
|
|
m_authenticationManagementService.logout();
|
|
}
|
|
|
|
void Controller::changePassword(const std::string& newPassword)
|
|
{
|
|
m_authenticationManagementService.changePassword(newPassword);
|
|
}
|
|
|
|
void Controller::createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone)
|
|
{
|
|
m_userManagementService.createUser(username, name, password, email, phone, util::UserType::CUSTOMER);
|
|
}
|
|
|
|
const User* Controller::getAuthenticatedUser()
|
|
{
|
|
return m_authenticationManagementService.getAuthenticatedUser();
|
|
}
|
|
|
|
void Controller::createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone)
|
|
{
|
|
}
|
|
|
|
void Controller::updateUserDetails(const std::string& email, const std::string& phone)
|
|
{
|
|
User* authenticatedUser = m_authenticationManagementService.getAuthenticatedUser();
|
|
if (authenticatedUser == nullptr)
|
|
{
|
|
throw std::runtime_error("No user currently logged in!");
|
|
}
|
|
m_userManagementService.updateUserDetails(authenticatedUser->getId(), email, phone);
|
|
}
|
|
|
|
util::Map<std::string, const Service*> Controller::getServices()
|
|
{
|
|
util::Map<std::string, Service*> currentServices = m_serviceManagementService.getServices();
|
|
util::Map<std::string, const Service*> readOnlyServices;
|
|
for (int iterator = 0; iterator < currentServices.getSize(); iterator++)
|
|
{
|
|
readOnlyServices.insert(currentServices.getValueAt(iterator)->getId(), currentServices.getValueAt(iterator));
|
|
}
|
|
return readOnlyServices;
|
|
}
|
|
|
|
util::Map<std::string, const ComboPackage*> Controller::getComboPackages()
|
|
{
|
|
return util::Map<std::string, const ComboPackage*>();
|
|
}
|
|
|
|
void Controller::purchaseService(const util::Vector<std::string>& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
|
|
{
|
|
m_serviceManagementService.purchaseService(serviceIDs, vehicleNumber, vehicleBrand, vehicleModel);
|
|
}
|
|
|
|
void Controller::purchaseComboPackage(const std::string& comboPackageID, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
|
|
{
|
|
m_serviceManagementService.purchaseComboPackage(comboPackageID, vehicleNumber, vehicleBrand, vehicleModel);
|
|
}
|
|
|
|
util::Map<std::string, const InventoryItem*> Controller::getInventoryItems()
|
|
{
|
|
util::Map<std::string, const InventoryItem*> dummyMap;
|
|
return dummyMap;
|
|
}
|
|
|
|
const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
void Controller::addInventoryItem(const std::string& partName, int quantity, double price)
|
|
{
|
|
}
|
|
|
|
void Controller::removeInventoryItem(const std::string& inventoryItemID)
|
|
{
|
|
}
|
|
|
|
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings()
|
|
{
|
|
auto serviceBookings = m_serviceManagementService.getServiceBookings();
|
|
util::Map<std::string, const ServiceBooking*> readOnlyServiceBookings;
|
|
for (int iterator = 0; iterator < serviceBookings.getSize(); iterator++)
|
|
{
|
|
readOnlyServiceBookings.insert(serviceBookings.getKeyAt(iterator), serviceBookings.getValueAt(iterator));
|
|
}
|
|
return readOnlyServiceBookings;
|
|
}
|
|
|
|
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookingsByUser(const std::string userID)
|
|
{
|
|
util::Map<std::string, const ServiceBooking*> readOnlyServiceBookingsByUserMap;
|
|
util::Map<std::string, ServiceBooking*> currentServiceBookingsByUser = m_serviceManagementService.getServiceBookings(userID);
|
|
for (int iterator = 0; iterator < currentServiceBookingsByUser.getSize(); iterator++)
|
|
{
|
|
readOnlyServiceBookingsByUserMap.insert(currentServiceBookingsByUser.getValueAt(iterator)->getId(), currentServiceBookingsByUser.getValueAt(iterator));
|
|
}
|
|
return readOnlyServiceBookingsByUserMap;
|
|
}
|
|
|
|
util::Map<std::string, const User*> Controller::getUsers()
|
|
{
|
|
return util::Map<std::string, const User*>();
|
|
}
|
|
|
|
util::Map<std::string, const User*> Controller::getUsers(util::UserType userType)
|
|
{
|
|
auto userMap = m_userManagementService.getUsers(userType);
|
|
util::Map<std::string, const User*> readOnlyUserMap;
|
|
for (int iterator = 0; iterator < userMap.getSize(); iterator++)
|
|
{
|
|
readOnlyUserMap.insert(userMap.getKeyAt(iterator), userMap.getValueAt(iterator));
|
|
}
|
|
return readOnlyUserMap;
|
|
}
|
|
|
|
void Controller::createJobCard(const std::string& bookingID, const std::string& technicianID, const std::string& serviceID)
|
|
{
|
|
m_serviceManagementService.createJobCard(bookingID, technicianID, serviceID);
|
|
}
|
|
|
|
void Controller::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost)
|
|
{
|
|
m_serviceManagementService.createService(name, inventoryItemIDs, laborCost);
|
|
}
|
|
|
|
void Controller::removeService(const std::string& serviceID)
|
|
{
|
|
m_serviceManagementService.removeService(serviceID);
|
|
}
|
|
|
|
util::Map<std::string, const JobCard*> Controller::getJobCardsByUser()
|
|
{
|
|
const User* currentUser = getAuthenticatedUser();
|
|
auto jobCardsAssignedToTechnician = m_serviceManagementService.getJobCards(currentUser->getId());
|
|
util::Map<std::string, const JobCard*> readOnlyJobCardMap;
|
|
for (int iterator = 0; iterator < jobCardsAssignedToTechnician.getSize(); iterator++)
|
|
{
|
|
JobCard* currentJobCard = jobCardsAssignedToTechnician.getValueAt(iterator);
|
|
readOnlyJobCardMap.insert(currentJobCard->getId(), currentJobCard);
|
|
}
|
|
return readOnlyJobCardMap;
|
|
}
|
|
|
|
void Controller::completeJob(const std::string& jobID)
|
|
{
|
|
m_serviceManagementService.completeJob(jobID);
|
|
}
|
|
|
|
void Controller::removeUser(const std::string& userID)
|
|
{
|
|
}
|
|
|
|
void Controller::createComboPackage(const std::string& name, const util::Vector<std::string>& serviceIDs, double discountPercentage)
|
|
{
|
|
}
|
|
|
|
void Controller::removeComboPackage(const std::string& comboPackageID)
|
|
{
|
|
}
|
|
|
|
util::Map<std::string, const Invoice*> Controller::getInvoicesByUser()
|
|
{
|
|
return util::Map<std::string, const Invoice*>();
|
|
}
|
|
|
|
void Controller::completePayment(const std::string& invoiceID, util::PaymentMode paymentMode)
|
|
{
|
|
}
|
|
|
|
util::Vector<const Notification*> Controller::getNotifications()
|
|
{
|
|
return util::Vector<const Notification*>();
|
|
}
|
|
|
|
void Controller::deleteNotification(const std::string& notificationID)
|
|
{
|
|
}
|
|
|
|
void Controller::configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications)
|
|
{
|
|
}
|
|
|
|
void Controller::runSystemChecks()
|
|
{
|
|
m_userManagementService.ensureAdminExists();
|
|
}
|
|
|