Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ca659c573 | |||
| 7e9cc27f1c | |||
| 1377d5fb39 | |||
| d33f0aa8dc | |||
| ef41fec208 | |||
| 3594fa4f26 | |||
| 6a8b845efa | |||
| 9f882610b3 |
-3
@@ -171,18 +171,15 @@
|
|||||||
<ClInclude Include="services\PaymentManagementService.h" />
|
<ClInclude Include="services\PaymentManagementService.h" />
|
||||||
<ClInclude Include="services\ServiceManagementService.h" />
|
<ClInclude Include="services\ServiceManagementService.h" />
|
||||||
<ClInclude Include="services\UserManagementService.h" />
|
<ClInclude Include="services\UserManagementService.h" />
|
||||||
<ClInclude Include="utilities\Config.h" />
|
|
||||||
<ClInclude Include="utilities\Enums.h" />
|
<ClInclude Include="utilities\Enums.h" />
|
||||||
<ClInclude Include="utilities\InputHelper.h" />
|
<ClInclude Include="utilities\InputHelper.h" />
|
||||||
<ClInclude Include="utilities\Map.h" />
|
<ClInclude Include="utilities\Map.h" />
|
||||||
<ClInclude Include="utilities\OutputHelper.h" />
|
<ClInclude Include="utilities\OutputHelper.h" />
|
||||||
<ClInclude Include="utilities\Timestamp.h" />
|
<ClInclude Include="utilities\Timestamp.h" />
|
||||||
<ClInclude Include="utilities\Utility.h" />
|
|
||||||
<ClInclude Include="utilities\Validator.h" />
|
<ClInclude Include="utilities\Validator.h" />
|
||||||
<ClInclude Include="utilities\Vector.h" />
|
<ClInclude Include="utilities\Vector.h" />
|
||||||
<ClInclude Include="views\AdminMenu.h" />
|
<ClInclude Include="views\AdminMenu.h" />
|
||||||
<ClInclude Include="views\CustomerMenu.h" />
|
<ClInclude Include="views\CustomerMenu.h" />
|
||||||
<ClInclude Include="views\MenuHelper.h" />
|
|
||||||
<ClInclude Include="views\TechnicianMenu.h" />
|
<ClInclude Include="views\TechnicianMenu.h" />
|
||||||
<ClInclude Include="views\UserInterface.h" />
|
<ClInclude Include="views\UserInterface.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
+62
-88
@@ -1,95 +1,48 @@
|
|||||||
/*
|
/*
|
||||||
File: Controller.cpp
|
File: Controller.cpp
|
||||||
Description: Implementation file containing the method definitions of the
|
Description: Implementation file containing the method definitions
|
||||||
Controller class, including authentication, user creation,
|
of the Controller class, which manages user authentication,
|
||||||
service purchasing, and system checks.
|
inventory, services, bookings, and notifications.
|
||||||
Author: Trenser
|
Author: Trenser
|
||||||
Date:19-May-2026
|
Date:19-May-2026
|
||||||
*/
|
*/
|
||||||
#include <stdexcept>
|
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
#include "Enums.h"
|
|
||||||
#include "User.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: login
|
Function: login
|
||||||
Description: Authenticates a user by delegating to the authentication management service.
|
Description: Authenticates a user based on provided credentials.
|
||||||
Parameter: const std::string& username - user’s username
|
Parameter: const std::string& username - the username of the user
|
||||||
const std::string& password - user’s password
|
const std::string& password - the password of the user
|
||||||
Return type: bool - true if login successful, false otherwise
|
Return type: bool
|
||||||
*/
|
*/
|
||||||
bool Controller::login(const std::string& username, const std::string& password)
|
bool Controller::login(const std::string& username, const std::string& password)
|
||||||
{
|
{
|
||||||
return m_authenticationManagementService.login(username, password);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: logout
|
|
||||||
Description: Logs out the currently authenticated user.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void Controller::logout()
|
void Controller::logout()
|
||||||
{
|
{
|
||||||
m_authenticationManagementService.logout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: changePassword
|
|
||||||
Description: Changes the password of the currently authenticated user.
|
|
||||||
Parameter: const std::string& newPassword - new password to set
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void Controller::changePassword(const std::string& newPassword)
|
void Controller::changePassword(const std::string& newPassword)
|
||||||
{
|
{
|
||||||
m_authenticationManagementService.changePassword(newPassword);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void Controller::createCustomer(const std::string& username, const std::string& password, const std::string& email, const std::string& phone)
|
||||||
Function: createCustomer
|
|
||||||
Description: Creates a new customer account with the provided details.
|
|
||||||
Parameter: const std::string& username - customer’s username
|
|
||||||
const std::string& name - customer’s name
|
|
||||||
const std::string& password - customer’s password
|
|
||||||
const std::string& email - customer’s email
|
|
||||||
const std::string& phone - customer’s phone number
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getAuthenticatedUser
|
|
||||||
Description: Retrieves the currently authenticated user.
|
|
||||||
Parameter: None
|
|
||||||
Return type: const User* - pointer to the authenticated user
|
|
||||||
*/
|
|
||||||
const User* Controller::getAuthenticatedUser()
|
const User* Controller::getAuthenticatedUser()
|
||||||
{
|
{
|
||||||
return m_authenticationManagementService.getAuthenticatedUser();
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone)
|
void Controller::createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: updateUserDetails
|
|
||||||
Description: Updates the email and phone details of the currently authenticated user.
|
|
||||||
Parameter: const std::string& email - new email address
|
|
||||||
const std::string& phone - new phone number
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void Controller::updateUserDetails(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, const Service*> Controller::getServices()
|
||||||
@@ -102,50 +55,78 @@ util::Map<std::string, const ComboPackage*> Controller::getComboPackages()
|
|||||||
return util::Map<std::string, const ComboPackage*>();
|
return util::Map<std::string, const ComboPackage*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: purchaseService
|
|
||||||
Description: Purchases one or more services for a vehicle by delegating to the service management service.
|
|
||||||
Parameter: const util::Vector<std::string>& serviceIDs - IDs of services to purchase
|
|
||||||
const std::string& vehicleNumber - vehicle registration number
|
|
||||||
const std::string& vehicleBrand - brand of the vehicle
|
|
||||||
const std::string& vehicleModel - model of the vehicle
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void Controller::purchaseService(const util::Vector<std::string>& serviceIDs, const std::string& vehicleNumber, const std::string& vehicleBrand, const std::string& vehicleModel)
|
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)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: purchaseComboPackage
|
Function: getInventoryItems
|
||||||
Description: Purchases a combo package for a vehicle by delegating to the service management service.
|
Description: Retrieves all inventory items from the inventory management service
|
||||||
Parameter: const std::string& comboPackageID - ID of the combo package
|
and constructs a read-only map for external use.
|
||||||
const std::string& vehicleNumber - vehicle registration number
|
Parameter: None
|
||||||
const std::string& vehicleBrand - brand of the vehicle
|
Return type: util::Map<std::string, const InventoryItem*>
|
||||||
const std::string& vehicleModel - model of the vehicle
|
|
||||||
Return type: void
|
|
||||||
*/
|
*/
|
||||||
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*> Controller::getInventoryItems()
|
||||||
{
|
{
|
||||||
return util::Map<std::string, const InventoryItem*>();
|
auto inventoryIems = m_inventoryManagementService.getInventoryItems();
|
||||||
|
util::Map<std::string, const InventoryItem*> readOnlyInventoryItems;
|
||||||
|
int inventoryItemsMapSize = inventoryIems.getSize();
|
||||||
|
for (int index = 0; index < inventoryItemsMapSize; index++)
|
||||||
|
{
|
||||||
|
readOnlyInventoryItems.insert(inventoryIems.getKeyAt(index), inventoryIems.getValueAt(index));
|
||||||
|
}
|
||||||
|
return readOnlyInventoryItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: getInventoryItem
|
||||||
|
Description: Retrieves a specific inventory item by its ID from the inventory management service.
|
||||||
|
Parameter: const std::string& inventoryItemID - ID of the inventory item
|
||||||
|
Return type: const InventoryItem*
|
||||||
|
*/
|
||||||
const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID)
|
const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return m_inventoryManagementService.getInventoryItem(inventoryItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: addInventoryItem
|
||||||
|
Description: Adds a new inventory item with specified details to the inventory management service.
|
||||||
|
Parameter: const std::string& partName - name of the part
|
||||||
|
int quantity - quantity of the part
|
||||||
|
double price - price of the part
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
void Controller::addInventoryItem(const std::string& partName, int quantity, double price)
|
void Controller::addInventoryItem(const std::string& partName, int quantity, double price)
|
||||||
{
|
{
|
||||||
|
m_inventoryManagementService.addInventoryItem(partName, quantity, price);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: removeInventoryItem
|
||||||
|
Description: Removes an inventory item from the inventory management service by its ID.
|
||||||
|
Parameter: const std::string& inventoryItemID - ID of the inventory item
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
void Controller::removeInventoryItem(const std::string& inventoryItemID)
|
void Controller::removeInventoryItem(const std::string& inventoryItemID)
|
||||||
{
|
{
|
||||||
|
m_inventoryManagementService.removeInventoryItem(inventoryItemID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: addInventoryItemStock
|
||||||
|
Description: Adds stock to an existing inventory item in the inventory management service.
|
||||||
|
Parameter: const std::string& selectedItemId - ID of the inventory item
|
||||||
|
int quantity - quantity to add
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
|
void Controller::addInventoryItemStock(const std::string& selectedItemId, int quantity)
|
||||||
|
{
|
||||||
|
m_inventoryManagementService.addInventoryItemStock(selectedItemId, quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings()
|
util::Map<std::string, const ServiceBooking*> Controller::getServiceBookings()
|
||||||
@@ -223,14 +204,7 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: runSystemChecks
|
|
||||||
Description: Runs system checks to ensure critical configurations, such as verifying admin existence.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void Controller::runSystemChecks()
|
void Controller::runSystemChecks()
|
||||||
{
|
{
|
||||||
m_userManagementService.ensureAdminExists();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
File: Controller.h
|
File: Controller.h
|
||||||
Description: Header file declaring the Controller class, which coordinates
|
Description: Header file declaring the Controller class, which manages
|
||||||
authentication, user management, service management, inventory,
|
user authentication, inventory, services, bookings, job cards,
|
||||||
and notifications across the Vehicle Service System.
|
invoices, and notifications in the system.
|
||||||
Author: Trenser
|
Author: Trenser
|
||||||
Date:19-May-2026
|
Date:19-May-2026
|
||||||
*/
|
*/
|
||||||
@@ -10,9 +10,7 @@ Date:19-May-2026
|
|||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
#include "AuthenticationManagementService.h"
|
#include "InventoryManagementService.h";
|
||||||
#include "UserManagementService.h"
|
|
||||||
#include "ServiceManagementService.h"
|
|
||||||
|
|
||||||
class Service;
|
class Service;
|
||||||
class ComboPackage;
|
class ComboPackage;
|
||||||
@@ -26,14 +24,12 @@ class Notification;
|
|||||||
class Controller
|
class Controller
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
AuthenticationManagementService m_authenticationManagementService;
|
InventoryManagementService m_inventoryManagementService;
|
||||||
UserManagementService m_userManagementService;
|
|
||||||
ServiceManagementService m_serviceManagementService;
|
|
||||||
public:
|
public:
|
||||||
bool login(const std::string& username, const std::string& password);
|
bool login(const std::string& username, const std::string& password);
|
||||||
void logout();
|
void logout();
|
||||||
void changePassword(const std::string& newPassword);
|
void changePassword(const std::string& newPassword);
|
||||||
void createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone);
|
void createCustomer(const std::string& username, const std::string& password, const std::string& email, const std::string& phone);
|
||||||
const User* getAuthenticatedUser();
|
const User* getAuthenticatedUser();
|
||||||
void createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone);
|
void createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone);
|
||||||
void updateUserDetails(const std::string& email, const std::string& phone);
|
void updateUserDetails(const std::string& email, const std::string& phone);
|
||||||
@@ -62,5 +58,6 @@ public:
|
|||||||
util::Vector<const Notification*> getNotifications();
|
util::Vector<const Notification*> getNotifications();
|
||||||
void deleteNotification(const std::string& notificationID);
|
void deleteNotification(const std::string& notificationID);
|
||||||
void configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications);
|
void configureNotifications(const std::string& userID, bool paymentNotifications, bool serviceNotifications);
|
||||||
|
void addInventoryItemStock(const std::string& selectedItemId, int quantity);
|
||||||
void runSystemChecks();
|
void runSystemChecks();
|
||||||
};
|
};
|
||||||
+8
-166
@@ -1,43 +1,14 @@
|
|||||||
/*
|
|
||||||
File: ServiceBooking.cpp
|
|
||||||
Description: Implementation file containing the method definitions of the
|
|
||||||
ServiceBooking class, including constructors, getters, and setters
|
|
||||||
for booking attributes.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#include "ServiceBooking.h"
|
#include "ServiceBooking.h"
|
||||||
|
|
||||||
int ServiceBooking::m_uid = 0;
|
int ServiceBooking::m_uid = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
Function: ServiceBooking
|
|
||||||
Description: Default constructor that initializes a new service booking
|
|
||||||
with a unique ID, no customer or technician, and zero discount.
|
|
||||||
Parameter: None
|
|
||||||
Return type: Constructor
|
|
||||||
*/
|
|
||||||
ServiceBooking::ServiceBooking()
|
ServiceBooking::ServiceBooking()
|
||||||
: m_id("SRV" + std::to_string(++m_uid)),
|
: m_id("SRV" + std::to_string(++m_uid)),
|
||||||
m_customer(nullptr),
|
m_customer(nullptr),
|
||||||
m_assignedTechnician(nullptr),
|
|
||||||
m_discountPercentage(0.0) {}
|
m_discountPercentage(0.0) {}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: ServiceBooking
|
|
||||||
Description: Parameterized constructor that initializes a service booking
|
|
||||||
with customer, vehicle, services, and discount details.
|
|
||||||
Parameter: util::ServiceJobStatus status - current booking status
|
|
||||||
const util::Map<std::string, Service*>& services - map of services
|
|
||||||
const std::string& customerId - ID of the customer
|
|
||||||
User* customer - pointer to the customer object
|
|
||||||
const std::string& vehicleNumber - vehicle registration number
|
|
||||||
const std::string& vehicleBrand - brand of the vehicle
|
|
||||||
const std::string& vehicleModel - model of the vehicle
|
|
||||||
double discountPercentage - discount applied to the booking
|
|
||||||
Return type: Constructor
|
|
||||||
*/
|
|
||||||
ServiceBooking::ServiceBooking(
|
ServiceBooking::ServiceBooking(
|
||||||
|
const std::string& id,
|
||||||
util::ServiceJobStatus status,
|
util::ServiceJobStatus status,
|
||||||
const util::Map<std::string,
|
const util::Map<std::string,
|
||||||
Service*>& services,
|
Service*>& services,
|
||||||
@@ -46,6 +17,8 @@ ServiceBooking::ServiceBooking(
|
|||||||
const std::string& vehicleNumber,
|
const std::string& vehicleNumber,
|
||||||
const std::string& vehicleBrand,
|
const std::string& vehicleBrand,
|
||||||
const std::string& vehicleModel,
|
const std::string& vehicleModel,
|
||||||
|
const std::string& assignedTechnicianId,
|
||||||
|
const std::string& assignedTechnician,
|
||||||
double discountPercentage
|
double discountPercentage
|
||||||
)
|
)
|
||||||
: m_id("SRV" + std::to_string(++m_uid)),
|
: m_id("SRV" + std::to_string(++m_uid)),
|
||||||
@@ -56,248 +29,117 @@ ServiceBooking::ServiceBooking(
|
|||||||
m_vehicleNumber(vehicleNumber),
|
m_vehicleNumber(vehicleNumber),
|
||||||
m_vehicleBrand(vehicleBrand),
|
m_vehicleBrand(vehicleBrand),
|
||||||
m_vehicleModel(vehicleModel),
|
m_vehicleModel(vehicleModel),
|
||||||
m_assignedTechnicianId(""),
|
m_assignedTechnicianId(assignedTechnicianId),
|
||||||
m_assignedTechnician(nullptr),
|
m_assignedTechnician(assignedTechnician),
|
||||||
m_discountPercentage(discountPercentage)
|
m_discountPercentage(discountPercentage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getId
|
|
||||||
Description: Retrieves the unique identifier of the service booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: const std::string&
|
|
||||||
*/
|
|
||||||
const std::string& ServiceBooking::getId() const
|
const std::string& ServiceBooking::getId() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getStatus
|
|
||||||
Description: Retrieves the current status of the service booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: util::ServiceJobStatus
|
|
||||||
*/
|
|
||||||
util::ServiceJobStatus ServiceBooking::getStatus() const
|
util::ServiceJobStatus ServiceBooking::getStatus() const
|
||||||
{
|
{
|
||||||
return m_status;
|
return m_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getServices
|
|
||||||
Description: Retrieves the services associated with the booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: const util::Map<std::string, Service*>&
|
|
||||||
*/
|
|
||||||
const util::Map<std::string, Service*>& ServiceBooking::getServices() const
|
const util::Map<std::string, Service*>& ServiceBooking::getServices() const
|
||||||
{
|
{
|
||||||
return m_services;
|
return m_services;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getCustomerId
|
|
||||||
Description: Retrieves the customer ID associated with the booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: const std::string&
|
|
||||||
*/
|
|
||||||
const std::string& ServiceBooking::getCustomerId() const
|
const std::string& ServiceBooking::getCustomerId() const
|
||||||
{
|
{
|
||||||
return m_customerId;
|
return m_customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getCustomer
|
|
||||||
Description: Retrieves the customer object associated with the booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: User*
|
|
||||||
*/
|
|
||||||
User* ServiceBooking::getCustomer() const
|
User* ServiceBooking::getCustomer() const
|
||||||
{
|
{
|
||||||
return m_customer;
|
return m_customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getVehicleNumber
|
|
||||||
Description: Retrieves the vehicle registration number for the booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: const std::string&
|
|
||||||
*/
|
|
||||||
const std::string& ServiceBooking::getVehicleNumber() const
|
const std::string& ServiceBooking::getVehicleNumber() const
|
||||||
{
|
{
|
||||||
return m_vehicleNumber;
|
return m_vehicleNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getVehicleBrand
|
|
||||||
Description: Retrieves the brand of the vehicle for the booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: const std::string&
|
|
||||||
*/
|
|
||||||
const std::string& ServiceBooking::getVehicleBrand() const
|
const std::string& ServiceBooking::getVehicleBrand() const
|
||||||
{
|
{
|
||||||
return m_vehicleBrand;
|
return m_vehicleBrand;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getVehicleModel
|
|
||||||
Description: Retrieves the model of the vehicle for the booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: const std::string&
|
|
||||||
*/
|
|
||||||
const std::string& ServiceBooking::getVehicleModel() const
|
const std::string& ServiceBooking::getVehicleModel() const
|
||||||
{
|
{
|
||||||
return m_vehicleModel;
|
return m_vehicleModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getAssignedTechnicianId
|
|
||||||
Description: Retrieves the ID of the technician assigned to the booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: const std::string&
|
|
||||||
*/
|
|
||||||
const std::string& ServiceBooking::getAssignedTechnicianId() const
|
const std::string& ServiceBooking::getAssignedTechnicianId() const
|
||||||
{
|
{
|
||||||
return m_assignedTechnicianId;
|
return m_assignedTechnicianId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
const std::string& ServiceBooking::getAssignedTechnician() const
|
||||||
Function: getAssignedTechnician
|
|
||||||
Description: Retrieves the technician object assigned to the booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: User*
|
|
||||||
*/
|
|
||||||
User* ServiceBooking::getAssignedTechnician() const
|
|
||||||
{
|
{
|
||||||
return m_assignedTechnician;
|
return m_assignedTechnician;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
Function: getDiscountPercentage
|
|
||||||
Description: Retrieves the discount percentage applied to the booking.
|
|
||||||
Parameter: None
|
|
||||||
Return type: double
|
|
||||||
*/
|
|
||||||
double ServiceBooking::getDiscountPercentage() const
|
double ServiceBooking::getDiscountPercentage() const
|
||||||
{
|
{
|
||||||
return m_discountPercentage;
|
return m_discountPercentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setId
|
|
||||||
Description: Sets the unique identifier of the service booking.
|
|
||||||
Parameter: const std::string& id - new booking ID
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setId(const std::string& id)
|
void ServiceBooking::setId(const std::string& id)
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setStatus
|
|
||||||
Description: Sets the current status of the service booking.
|
|
||||||
Parameter: const util::ServiceJobStatus& status - new booking status
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setStatus(const util::ServiceJobStatus& status)
|
void ServiceBooking::setStatus(const util::ServiceJobStatus& status)
|
||||||
{
|
{
|
||||||
m_status = status;
|
m_status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setServices
|
|
||||||
Description: Sets the services associated with the booking.
|
|
||||||
Parameter: const util::Map<std::string, Service*>& services - new services map
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setServices(const util::Map<std::string, Service*>& services)
|
void ServiceBooking::setServices(const util::Map<std::string, Service*>& services)
|
||||||
{
|
{
|
||||||
m_services = services;
|
m_services = services;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setCustomerId
|
|
||||||
Description: Sets the customer ID for the booking.
|
|
||||||
Parameter: const std::string& customerId - new customer ID
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setCustomerId(const std::string& customerId)
|
void ServiceBooking::setCustomerId(const std::string& customerId)
|
||||||
{
|
{
|
||||||
m_customerId = customerId;
|
m_customerId = customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setCustomer
|
|
||||||
Description: Sets the customer object for the booking.
|
|
||||||
Parameter: User* customer - pointer to the customer object
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setCustomer(User* customer)
|
void ServiceBooking::setCustomer(User* customer)
|
||||||
{
|
{
|
||||||
m_customer = customer;
|
m_customer = customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setVehicleNumber
|
|
||||||
Description: Sets the vehicle registration number for the booking.
|
|
||||||
Parameter: const std::string& vehicleNumber - new vehicle number
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setVehicleNumber(const std::string& vehicleNumber)
|
void ServiceBooking::setVehicleNumber(const std::string& vehicleNumber)
|
||||||
{
|
{
|
||||||
m_vehicleNumber = vehicleNumber;
|
m_vehicleNumber = vehicleNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setVehicleBrand
|
|
||||||
Description: Sets the brand of the vehicle for the booking.
|
|
||||||
Parameter: const std::string& vehicleBrand - new vehicle brand
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setVehicleBrand(const std::string& vehicleBrand)
|
void ServiceBooking::setVehicleBrand(const std::string& vehicleBrand)
|
||||||
{
|
{
|
||||||
m_vehicleBrand = vehicleBrand;
|
m_vehicleBrand = vehicleBrand;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setVehicleModel
|
|
||||||
Description: Sets the model of the vehicle for the booking.
|
|
||||||
Parameter: const std::string& vehicleModel - new vehicle model
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setVehicleModel(const std::string& vehicleModel)
|
void ServiceBooking::setVehicleModel(const std::string& vehicleModel)
|
||||||
{
|
{
|
||||||
m_vehicleModel = vehicleModel;
|
m_vehicleModel = vehicleModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setAssignedTechnicianId
|
|
||||||
Description: Sets the ID of the technician assigned to the booking.
|
|
||||||
Parameter: const std::string& assignedTechnicianId - new technician ID
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnicianId)
|
void ServiceBooking::setAssignedTechnicianId(const std::string& assignedTechnicianId)
|
||||||
{
|
{
|
||||||
m_assignedTechnicianId = assignedTechnicianId;
|
m_assignedTechnicianId = assignedTechnicianId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ServiceBooking::setAssignedTechnician(const std::string& assignedTechnician)
|
||||||
Function: setAssignedTechnician
|
|
||||||
Description: Sets the technician object assigned to the booking.
|
|
||||||
Parameter: User* assignedTechnician - pointer to the technician object
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setAssignedTechnician(User* assignedTechnician)
|
|
||||||
{
|
{
|
||||||
m_assignedTechnician = assignedTechnician;
|
m_assignedTechnician = assignedTechnician;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: setDiscountPercentage
|
|
||||||
Description: Sets the discount percentage for the booking.
|
|
||||||
Parameter: double discountPercentage - new discount percentage
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceBooking::setDiscountPercentage(double discountPercentage)
|
void ServiceBooking::setDiscountPercentage(double discountPercentage)
|
||||||
{
|
{
|
||||||
m_discountPercentage = discountPercentage;
|
m_discountPercentage = discountPercentage;
|
||||||
|
|||||||
@@ -1,11 +1,3 @@
|
|||||||
/*
|
|
||||||
File: ServiceBooking.h
|
|
||||||
Description: Header file declaring the ServiceBooking class, which represents
|
|
||||||
a booking of services by a customer, including vehicle details,
|
|
||||||
assigned technician, and discount information.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
@@ -27,11 +19,12 @@ private:
|
|||||||
std::string m_vehicleBrand;
|
std::string m_vehicleBrand;
|
||||||
std::string m_vehicleModel;
|
std::string m_vehicleModel;
|
||||||
std::string m_assignedTechnicianId;
|
std::string m_assignedTechnicianId;
|
||||||
User* m_assignedTechnician;
|
std::string m_assignedTechnician;
|
||||||
double m_discountPercentage;
|
double m_discountPercentage;
|
||||||
public:
|
public:
|
||||||
ServiceBooking();
|
ServiceBooking();
|
||||||
ServiceBooking(
|
ServiceBooking(
|
||||||
|
const std::string& id,
|
||||||
util::ServiceJobStatus status,
|
util::ServiceJobStatus status,
|
||||||
const util::Map<std::string,
|
const util::Map<std::string,
|
||||||
Service*>& services,
|
Service*>& services,
|
||||||
@@ -40,6 +33,8 @@ public:
|
|||||||
const std::string& vehicleNumber,
|
const std::string& vehicleNumber,
|
||||||
const std::string& vehicleBrand,
|
const std::string& vehicleBrand,
|
||||||
const std::string& vehicleModel,
|
const std::string& vehicleModel,
|
||||||
|
const std::string& assignedTechnicianId,
|
||||||
|
const std::string& assignedTechnician,
|
||||||
double discountPercentage
|
double discountPercentage
|
||||||
);
|
);
|
||||||
const std::string& getId() const;
|
const std::string& getId() const;
|
||||||
@@ -51,7 +46,7 @@ public:
|
|||||||
const std::string& getVehicleBrand() const;
|
const std::string& getVehicleBrand() const;
|
||||||
const std::string& getVehicleModel() const;
|
const std::string& getVehicleModel() const;
|
||||||
const std::string& getAssignedTechnicianId() const;
|
const std::string& getAssignedTechnicianId() const;
|
||||||
User* getAssignedTechnician() const;
|
const std::string& getAssignedTechnician() const;
|
||||||
double getDiscountPercentage() const;
|
double getDiscountPercentage() const;
|
||||||
void setId(const std::string& id);
|
void setId(const std::string& id);
|
||||||
void setStatus(const util::ServiceJobStatus& status);
|
void setStatus(const util::ServiceJobStatus& status);
|
||||||
@@ -62,6 +57,6 @@ public:
|
|||||||
void setVehicleBrand(const std::string& vehicleBrand);
|
void setVehicleBrand(const std::string& vehicleBrand);
|
||||||
void setVehicleModel(const std::string& vehicleModel);
|
void setVehicleModel(const std::string& vehicleModel);
|
||||||
void setAssignedTechnicianId(const std::string& assignedTechnicianId);
|
void setAssignedTechnicianId(const std::string& assignedTechnicianId);
|
||||||
void setAssignedTechnician(User* assignedTechnician);
|
void setAssignedTechnician(const std::string& assignedTechnician);
|
||||||
void setDiscountPercentage(double discountPercentage);
|
void setDiscountPercentage(double discountPercentage);
|
||||||
};
|
};
|
||||||
-78
@@ -1,81 +1,3 @@
|
|||||||
/*
|
|
||||||
File: AuthenticationManagementService.cpp
|
|
||||||
Description: Implementation file containing the method definitions of the
|
|
||||||
AuthenticationManagementService class, including login, logout,
|
|
||||||
password change, and retrieval of the authenticated user.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#include <stdexcept>
|
|
||||||
#include "AuthenticationManagementService.h"
|
#include "AuthenticationManagementService.h"
|
||||||
#include "User.h"
|
|
||||||
|
|
||||||
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
|
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
|
||||||
|
|
||||||
/*
|
|
||||||
Function: login
|
|
||||||
Description: Authenticates a user by checking the provided username and password
|
|
||||||
against the stored users in the DataStore. If successful, sets the
|
|
||||||
authenticated user.
|
|
||||||
Parameter: const std::string& username - user’s username
|
|
||||||
const std::string& password - user’s password
|
|
||||||
Return type: bool - true if login successful, false otherwise
|
|
||||||
*/
|
|
||||||
bool AuthenticationManagementService::login(const std::string& username, const std::string& password)
|
|
||||||
{
|
|
||||||
util::Map<std::string, User*> users = m_dataStore.getUsers();
|
|
||||||
int usersMapSize = users.getSize();
|
|
||||||
for (int index = 0; index < usersMapSize; index++)
|
|
||||||
{
|
|
||||||
User* user = users.getValueAt(index);
|
|
||||||
if (username == user->getUserName())
|
|
||||||
{
|
|
||||||
if (password == user->getPassword())
|
|
||||||
{
|
|
||||||
m_authenticatedUser = user;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: getAuthenticatedUser
|
|
||||||
Description: Retrieves the currently authenticated user.
|
|
||||||
Parameter: None
|
|
||||||
Return type: User* - pointer to the authenticated user
|
|
||||||
*/
|
|
||||||
User* AuthenticationManagementService::getAuthenticatedUser()
|
|
||||||
{
|
|
||||||
return m_authenticatedUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: logout
|
|
||||||
Description: Logs out the currently authenticated user by clearing the
|
|
||||||
static authenticated user pointer.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void AuthenticationManagementService::logout()
|
|
||||||
{
|
|
||||||
m_authenticatedUser = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: changePassword
|
|
||||||
Description: Changes the password of the currently authenticated user.
|
|
||||||
Throws an exception if no user is logged in.
|
|
||||||
Parameter: const std::string& newPassword - new password to set
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void AuthenticationManagementService::changePassword(const std::string& newPassword)
|
|
||||||
{
|
|
||||||
if (m_authenticatedUser == nullptr)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("There is no user currently logged in!");
|
|
||||||
}
|
|
||||||
m_authenticatedUser->setPassword(newPassword);
|
|
||||||
}
|
|
||||||
|
|||||||
-8
@@ -1,11 +1,3 @@
|
|||||||
/*
|
|
||||||
File: AuthenticationManagementService.h
|
|
||||||
Description: Header file declaring the AuthenticationManagementService class, which manages
|
|
||||||
user authentication, login, logout, password changes, and retrieval of the
|
|
||||||
authenticated user.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "DataStore.h"
|
#include "DataStore.h"
|
||||||
|
|||||||
+92
@@ -1 +1,93 @@
|
|||||||
|
/*
|
||||||
|
File: InventoryManagementService.cpp
|
||||||
|
Description: Implementation file containing the method definitions of the
|
||||||
|
InventoryManagementService class, including inventory operations
|
||||||
|
and notification handling.
|
||||||
|
Author: Trenser
|
||||||
|
Date:19-May-2026
|
||||||
|
*/
|
||||||
#include "InventoryManagementService.h"
|
#include "InventoryManagementService.h"
|
||||||
|
#include "InventoryItem.h"
|
||||||
|
#include "Factory.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: addInventoryItem
|
||||||
|
Description: Creates a new inventory item using the Factory and inserts it
|
||||||
|
into the DataStore.
|
||||||
|
Parameter: const std::string& partName - name of the part
|
||||||
|
int quantity - initial quantity of the part
|
||||||
|
double price - price of the part
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
|
void InventoryManagementService::addInventoryItem(const std::string& partName, int quantity, double price)
|
||||||
|
{
|
||||||
|
InventoryItem* newItem = Factory::getObject<InventoryItem>(partName, quantity, price);
|
||||||
|
m_dataStore.getInventoryItems().insert(newItem->getId(), newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: addInventoryItemStock
|
||||||
|
Description: Increases the stock quantity of an existing inventory item.
|
||||||
|
Parameter: const std::string& selectedItemId - ID of the inventory item
|
||||||
|
int quantity - quantity to add
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
|
void InventoryManagementService::addInventoryItemStock(const std::string& selectedItemId, int quantity)
|
||||||
|
{
|
||||||
|
int index = m_dataStore.getInventoryItems().find(selectedItemId);
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
InventoryItem* item = m_dataStore.getInventoryItems().getValueAt(index);
|
||||||
|
if (item != nullptr)
|
||||||
|
{
|
||||||
|
int totalQuantity = item->getQuantity() + quantity;
|
||||||
|
item->setQuantity(totalQuantity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: getInventoryItems
|
||||||
|
Description: Retrieves all inventory items stored in the DataStore.
|
||||||
|
Parameter: None
|
||||||
|
Return type: util::Map<std::string, InventoryItem*>
|
||||||
|
*/
|
||||||
|
util::Map<std::string, InventoryItem*> InventoryManagementService::getInventoryItems()
|
||||||
|
{
|
||||||
|
return m_dataStore.getInventoryItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: removeInventoryItem
|
||||||
|
Description: Marks an inventory item as inactive instead of deleting it.
|
||||||
|
Parameter: const std::string& inventoryItemID - ID of the inventory item
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
|
void InventoryManagementService::removeInventoryItem(const std::string& inventoryItemID)
|
||||||
|
{
|
||||||
|
int index = m_dataStore.getInventoryItems().find(inventoryItemID);
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
InventoryItem* item = m_dataStore.getInventoryItems().getValueAt(index);
|
||||||
|
if (item != nullptr)
|
||||||
|
{
|
||||||
|
item->setState(util::State::INACTIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: getInventoryItem
|
||||||
|
Description: Retrieves a specific inventory item by its ID from the DataStore.
|
||||||
|
Parameter: const std::string& inventoryItemID - ID of the inventory item
|
||||||
|
Return type: InventoryItem*
|
||||||
|
*/
|
||||||
|
InventoryItem* InventoryManagementService::getInventoryItem(const std::string& inventoryItemID)
|
||||||
|
{
|
||||||
|
int index = m_dataStore.getInventoryItems().find(inventoryItemID);
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
return m_dataStore.getInventoryItems().getValueAt(index);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
+9
@@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
File: InventoryManagementService.h
|
||||||
|
Description: Header file declaring the InventoryManagementService class,
|
||||||
|
which manages inventory items, stock updates, and notifications
|
||||||
|
related to low stock alerts. Inherits from NotificationManagementService.
|
||||||
|
Author: Trenser
|
||||||
|
Date:19-May-2026
|
||||||
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
@@ -17,6 +25,7 @@ public:
|
|||||||
InventoryItem* getInventoryItem(const std::string& inventoryItemID);
|
InventoryItem* getInventoryItem(const std::string& inventoryItemID);
|
||||||
void addInventoryItem(const std::string& partName, int quantity, double price);
|
void addInventoryItem(const std::string& partName, int quantity, double price);
|
||||||
void removeInventoryItem(const std::string& inventoryItemID);
|
void removeInventoryItem(const std::string& inventoryItemID);
|
||||||
|
void addInventoryItemStock(const std::string& selectedItemId, int quantity);
|
||||||
void sendLowStockAlerts();
|
void sendLowStockAlerts();
|
||||||
void sendNotification(User* user, const std::string& title, const std::string& message) override;
|
void sendNotification(User* user, const std::string& title, const std::string& message) override;
|
||||||
void attach(User* user) override;
|
void attach(User* user) override;
|
||||||
|
|||||||
-97
@@ -1,98 +1 @@
|
|||||||
/*
|
|
||||||
File: ServiceManagementService.cpp
|
|
||||||
Description: Implementation file containing the method definitions of the
|
|
||||||
ServiceManagementService class, including service and combo package
|
|
||||||
purchasing logic, booking creation, and notification handling.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#include <stdexcept>
|
|
||||||
#include "ServiceManagementService.h"
|
#include "ServiceManagementService.h"
|
||||||
#include "AuthenticationManagementService.h"
|
|
||||||
#include "Service.h"
|
|
||||||
#include "ServiceBooking.h"
|
|
||||||
#include "ComboPackage.h"
|
|
||||||
#include "Factory.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: purchaseService
|
|
||||||
Description: Creates a new service booking for the authenticated user. Validates
|
|
||||||
service IDs, retrieves services from the DataStore, and generates a
|
|
||||||
booking. Sends a notification upon successful booking.
|
|
||||||
Parameter: const util::Vector<std::string>& serviceIDs - IDs of services to purchase
|
|
||||||
const std::string& vehicleNumber - vehicle registration number
|
|
||||||
const std::string& vehicleBrand - brand of the vehicle
|
|
||||||
const std::string& vehicleModel - model of the vehicle
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void ServiceManagementService::purchaseService(const util::Vector<std::string>& serviceIDs, 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& servicesMap = m_dataStore.getServices();
|
|
||||||
auto& serviceBookingMap = m_dataStore.getServiceBookings();
|
|
||||||
util::Map<std::string, Service*> selectedServices;
|
|
||||||
int selectedServicesCount = serviceIDs.getSize();
|
|
||||||
for (int index = 0; index < selectedServicesCount; index++)
|
|
||||||
{
|
|
||||||
int serviceIndex = servicesMap.find(serviceIDs[index]);
|
|
||||||
if (serviceIndex == -1)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Service not found!");
|
|
||||||
}
|
|
||||||
Service* service = servicesMap.getValueAt(serviceIndex);
|
|
||||||
selectedServices[service->getId()] = service;
|
|
||||||
}
|
|
||||||
ServiceBooking* serviceBooking = Factory::getObject<ServiceBooking>(util::ServiceJobStatus::STARTED, selectedServices, authenticatedUser->getId(), authenticatedUser, vehicleNumber, vehicleBrand, vehicleModel, 0);
|
|
||||||
if (serviceBooking == nullptr)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Failed to create service booking");
|
|
||||||
}
|
|
||||||
serviceBookingMap[serviceBooking->getId()] = serviceBooking;
|
|
||||||
sendNotification(authenticatedUser,
|
|
||||||
"Service Booking succeeded",
|
|
||||||
"Your service booking has been successfully placed with ID " + serviceBooking->getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: purchaseComboPackage
|
|
||||||
Description: Creates a new service booking for a combo package. Validates the combo
|
|
||||||
package ID, retrieves services from the package, and generates a booking
|
|
||||||
with the applicable discount. Sends a notification upon successful booking.
|
|
||||||
Parameter: const std::string& comboPackageID - ID of the combo package
|
|
||||||
const std::string& vehicleNumber - vehicle registration number
|
|
||||||
const std::string& vehicleBrand - brand of the vehicle
|
|
||||||
const std::string& vehicleModel - model of the vehicle
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|||||||
-8
@@ -1,11 +1,3 @@
|
|||||||
/*
|
|
||||||
File: ServiceManagementService.h
|
|
||||||
Description: Header file declaring the ServiceManagementService class, which manages
|
|
||||||
services, combo packages, job cards, and service bookings. Inherits from
|
|
||||||
NotificationManagementService to handle notifications.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
|
|||||||
-111
@@ -1,112 +1 @@
|
|||||||
/*
|
|
||||||
File: UserManagementService.cpp
|
|
||||||
Description: Implementation file containing the method definitions of the
|
|
||||||
UserManagementService class, including user creation, updates,
|
|
||||||
and ensuring an admin account exists.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#include <stdexcept>
|
|
||||||
#include "User.h"
|
|
||||||
#include "Enums.h"
|
|
||||||
#include "Config.h"
|
|
||||||
#include "UserManagementService.h"
|
#include "UserManagementService.h"
|
||||||
#include "ServiceManagementService.h"
|
|
||||||
#include "PaymentManagementService.h"
|
|
||||||
#include "InventoryManagementService.h"
|
|
||||||
#include "Factory.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: ensureAdminExists
|
|
||||||
Description: Ensures that at least one admin user exists in the system.
|
|
||||||
If no admin is found, creates a default admin user using
|
|
||||||
configuration constants.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void UserManagementService::ensureAdminExists()
|
|
||||||
{
|
|
||||||
auto& usersMap = m_dataStore.getUsers();
|
|
||||||
int usersMapSize = usersMap.getSize();
|
|
||||||
bool isAdminFound = false;
|
|
||||||
for (int index = 0; index < usersMapSize; index++)
|
|
||||||
{
|
|
||||||
User* user = usersMap.getValueAt(index);
|
|
||||||
if (user && user->getUserType() == util::UserType::ADMIN)
|
|
||||||
{
|
|
||||||
isAdminFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isAdminFound)
|
|
||||||
{
|
|
||||||
createUser(
|
|
||||||
config::admin::DEFAULT_ADMIN_USERNAME,
|
|
||||||
config::admin::DEFAULT_ADMIN_NAME,
|
|
||||||
config::admin::DEFAULT_ADMIN_PASSWORD,
|
|
||||||
config::admin::DEFAULT_ADMIN_EMAIL,
|
|
||||||
config::admin::DEFAULT_ADMIN_PHONE,
|
|
||||||
util::UserType::ADMIN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: createUser
|
|
||||||
Description: Creates a new user with the provided details. Validates that
|
|
||||||
the username is unique, then attaches the user to relevant
|
|
||||||
management services (payment, service, inventory).
|
|
||||||
Parameter: const std::string& username - user’s username
|
|
||||||
const std::string& name - user’s name
|
|
||||||
const std::string& password - user’s password
|
|
||||||
const std::string& email - user’s email address
|
|
||||||
const std::string& phone - user’s phone number
|
|
||||||
util::UserType type - type of user (ADMIN, CUSTOMER, TECHNICIAN)
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void UserManagementService::createUser(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone, util::UserType type)
|
|
||||||
{
|
|
||||||
InventoryManagementService inventoryManagementService;
|
|
||||||
PaymentManagementService paymentManagementService;
|
|
||||||
ServiceManagementService serviceManagementService;
|
|
||||||
auto& usersMap = m_dataStore.getUsers();
|
|
||||||
int index = usersMap.findIf(
|
|
||||||
[&](const std::string&, User* user)
|
|
||||||
{
|
|
||||||
return user->getUserName() == username;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Username already exists");
|
|
||||||
}
|
|
||||||
User* newUser = Factory::getObject<User>(username, password, name, phone, email, type);
|
|
||||||
usersMap.insert(newUser->getId(), newUser);
|
|
||||||
paymentManagementService.attach(newUser);
|
|
||||||
serviceManagementService.attach(newUser);
|
|
||||||
if (newUser->getUserType() == util::UserType::ADMIN)
|
|
||||||
{
|
|
||||||
inventoryManagementService.attach(newUser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: updateUserDetails
|
|
||||||
Description: Updates the email and phone details of an existing user.
|
|
||||||
Throws an exception if the user does not exist.
|
|
||||||
Parameter: const std::string& userID - ID of the user to update
|
|
||||||
const std::string& email - new email address
|
|
||||||
const std::string& phone - new phone number
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void UserManagementService::updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone)
|
|
||||||
{
|
|
||||||
auto& usersMap = m_dataStore.getUsers();
|
|
||||||
int index = usersMap.find(userID);
|
|
||||||
if (index == -1)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("User does not exist!");
|
|
||||||
}
|
|
||||||
User* user = usersMap.getValueAt(index);
|
|
||||||
user->setEmail(email);
|
|
||||||
user->setPhone(phone);
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-10
@@ -1,11 +1,3 @@
|
|||||||
/*
|
|
||||||
File: UserManagementService.h
|
|
||||||
Description: Header file declaring the UserManagementService class, which manages
|
|
||||||
user creation, updates, retrieval, removal, notifications, and ensures
|
|
||||||
the existence of an admin account.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
@@ -21,7 +13,7 @@ private:
|
|||||||
DataStore& m_dataStore;
|
DataStore& m_dataStore;
|
||||||
public:
|
public:
|
||||||
UserManagementService() : m_dataStore(DataStore::getInstance()) {}
|
UserManagementService() : m_dataStore(DataStore::getInstance()) {}
|
||||||
void createUser(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone, util::UserType type);
|
void createUser(const std::string& username, const std::string& password, const std::string& email, const std::string& phone, util::UserType type);
|
||||||
void updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone);
|
void updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone);
|
||||||
util::Map<std::string, User*> getUsers();
|
util::Map<std::string, User*> getUsers();
|
||||||
util::Map<std::string, User*> getUsers(util::UserType type);
|
util::Map<std::string, User*> getUsers(util::UserType type);
|
||||||
@@ -29,5 +21,4 @@ public:
|
|||||||
void removeUser(const std::string& userID);
|
void removeUser(const std::string& userID);
|
||||||
util::Vector<Notification*> getUserNotifications(const std::string& userID);
|
util::Vector<Notification*> getUserNotifications(const std::string& userID);
|
||||||
void deleteNotification(const std::string& notificationID, const std::string& userID);
|
void deleteNotification(const std::string& notificationID, const std::string& userID);
|
||||||
void ensureAdminExists();
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
File: Config.h
|
|
||||||
Description: Header file declaring configuration constants for the Vehicle Service System.
|
|
||||||
Includes default admin account details such as username, name, password,
|
|
||||||
email, and phone number.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace config
|
|
||||||
{
|
|
||||||
namespace admin
|
|
||||||
{
|
|
||||||
constexpr const char* DEFAULT_ADMIN_USERNAME = "admin";
|
|
||||||
constexpr const char* DEFAULT_ADMIN_NAME = "admin";
|
|
||||||
constexpr const char* DEFAULT_ADMIN_PASSWORD = "";
|
|
||||||
constexpr const char* DEFAULT_ADMIN_EMAIL = "admin@vss";
|
|
||||||
constexpr const char* DEFAULT_ADMIN_PHONE = "0000000000";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
File: Utility.h
|
|
||||||
Description: Header file declaring utility functions used across the system,
|
|
||||||
including cost calculation for services and combo packages.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
#include "Service.h"
|
|
||||||
#include "InventoryItem.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: calculatePartsCost
|
|
||||||
Description: Calculates the total cost of parts required for a given service
|
|
||||||
by summing the prices of all associated inventory items.
|
|
||||||
Parameter: const Service* service - pointer to the service object
|
|
||||||
Return type: double - total cost of required parts
|
|
||||||
*/
|
|
||||||
inline double calculatePartsCost(const Service* service)
|
|
||||||
{
|
|
||||||
double cost = 0;
|
|
||||||
auto& requiredInventoryItems = service->getRequiredInventoryItems();
|
|
||||||
int requiredInventoryItemsSize = requiredInventoryItems.getSize();
|
|
||||||
for (int index = 0; index < requiredInventoryItemsSize; index++)
|
|
||||||
{
|
|
||||||
cost += requiredInventoryItems.getValueAt(index)->getPrice();
|
|
||||||
}
|
|
||||||
return cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: calculateComboServiceEstimatedCost
|
|
||||||
Description: Calculates the estimated total cost of a combo package by summing
|
|
||||||
the labor and parts costs of all services included in the package.
|
|
||||||
Parameter: const ComboPackage* comboPackage - pointer to the combo package object
|
|
||||||
Return type: double - estimated total cost of the combo package
|
|
||||||
*/
|
|
||||||
inline double calculateComboServiceEstimatedCost(const ComboPackage* comboPackage)
|
|
||||||
{
|
|
||||||
double cost = 0;
|
|
||||||
auto& services = comboPackage->getServices();
|
|
||||||
int servicesSize = services.getSize();
|
|
||||||
for (int index = 0; index < servicesSize; index++)
|
|
||||||
{
|
|
||||||
const Service* service = services.getValueAt(index);
|
|
||||||
cost += calculatePartsCost(service) + service->getLaborCost();
|
|
||||||
}
|
|
||||||
return cost;
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,23 @@
|
|||||||
|
/*
|
||||||
|
File: AdminMenu.cpp
|
||||||
|
Description: Implementation file containing the method definitions of the
|
||||||
|
AdminMenu class, including menu handling, inventory operations,
|
||||||
|
and stock management functions.
|
||||||
|
Author: Trenser
|
||||||
|
Date:19-May-2026
|
||||||
|
*/
|
||||||
|
#include <iomanip>
|
||||||
#include "AdminMenu.h"
|
#include "AdminMenu.h"
|
||||||
|
#include "InventoryItem.h"
|
||||||
#include "InputHelper.h"
|
#include "InputHelper.h"
|
||||||
#include "OutputHelper.h"
|
#include "OutputHelper.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: showMenu
|
||||||
|
Description: Displays the admin menu and handles user input until the menu is exited.
|
||||||
|
Parameter: None
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
void AdminMenu::showMenu()
|
void AdminMenu::showMenu()
|
||||||
{
|
{
|
||||||
bool isMenuActive = true;
|
bool isMenuActive = true;
|
||||||
@@ -40,20 +56,252 @@ void AdminMenu::changePassword()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: viewStockLevels
|
||||||
|
Description: Displays all active inventory items with their details
|
||||||
|
including ID, part name, quantity, and price.
|
||||||
|
Parameter: None
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
void AdminMenu::viewStockLevels()
|
void AdminMenu::viewStockLevels()
|
||||||
{
|
{
|
||||||
|
auto inventoryItems = m_controller.getInventoryItems();
|
||||||
|
std::cout << std::left << std::setw(15) << "Item ID"
|
||||||
|
<< std::setw(25) << "Part Name"
|
||||||
|
<< std::setw(10) << "Quantity"
|
||||||
|
<< std::setw(10) << "Price"
|
||||||
|
<< std::endl;
|
||||||
|
for (int iterator = 0; iterator < inventoryItems.getSize(); ++iterator)
|
||||||
|
{
|
||||||
|
const InventoryItem* item = inventoryItems.getValueAt(iterator);
|
||||||
|
if (item != nullptr)
|
||||||
|
{
|
||||||
|
if (item->getState() != util::State::INACTIVE)
|
||||||
|
{
|
||||||
|
std::cout << std::left << std::setw(15) << item->getId()
|
||||||
|
<< std::setw(25) << item->getPartName()
|
||||||
|
<< std::setw(10) << item->getQuantity()
|
||||||
|
<< std::setw(10) << item->getPrice()
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: filterActiveItems
|
||||||
|
Description: Filters out inactive inventory items and returns a map
|
||||||
|
containing only active items.
|
||||||
|
Parameter: const util::Map<std::string, const InventoryItem*>& inventoryItems -
|
||||||
|
map of all inventory items
|
||||||
|
Return type: util::Map<std::string, const InventoryItem*>
|
||||||
|
*/
|
||||||
|
static util::Map<std::string, const InventoryItem*>
|
||||||
|
filterActiveItems(const util::Map<std::string, const InventoryItem*>& inventoryItems)
|
||||||
|
{
|
||||||
|
util::Map<std::string, const InventoryItem*> activeItems;
|
||||||
|
int inventorySize = inventoryItems.getSize();
|
||||||
|
for (int index = 0; index < inventorySize; index++)
|
||||||
|
{
|
||||||
|
const InventoryItem* item = inventoryItems.getValueAt(index);
|
||||||
|
if (item != nullptr && item->getState() != util::State::INACTIVE)
|
||||||
|
{
|
||||||
|
activeItems.insert(item->getId(), item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return activeItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: displayInventoryWithItems
|
||||||
|
Description: Displays inventory items in a tabular format with index, ID,
|
||||||
|
part name, quantity, and price.
|
||||||
|
Parameter: util::Map<std::string, const InventoryItem*>& inventoryItems -
|
||||||
|
map of inventory items to display
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
|
static void displayInventoryWithItems(util::Map<std::string, const InventoryItem*>& inventoryItems)
|
||||||
|
{
|
||||||
|
int inventorySize = inventoryItems.getSize();
|
||||||
|
std::cout << std::left << std::setw(10) << "Index"
|
||||||
|
<< std::setw(15) << "Item ID"
|
||||||
|
<< std::setw(25) << "Part Name"
|
||||||
|
<< std::setw(10) << "Quantity"
|
||||||
|
<< std::setw(10) << "Price"
|
||||||
|
<< std::endl;
|
||||||
|
for (int iterator = 0; iterator < inventorySize; iterator++)
|
||||||
|
{
|
||||||
|
const InventoryItem* item = inventoryItems.getValueAt(iterator);
|
||||||
|
if (item != nullptr)
|
||||||
|
{
|
||||||
|
std::cout << std::left << std::setw(10) << (iterator + 1)
|
||||||
|
<< std::setw(15) << item->getId()
|
||||||
|
<< std::setw(25) << item->getPartName()
|
||||||
|
<< std::setw(10) << item->getQuantity()
|
||||||
|
<< std::setw(10) << item->getPrice()
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: addQuantityToItem
|
||||||
|
Description: Allows the admin to select an active inventory item and
|
||||||
|
increase its stock quantity.
|
||||||
|
Parameter: util::Map<std::string, const InventoryItem*>& inventoryItems -
|
||||||
|
map of inventory items
|
||||||
|
Controller& m_controller - controller instance to update stock
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
|
static void addQuantityToItem(util::Map<std::string, const InventoryItem*>& inventoryItems, Controller& m_controller)
|
||||||
|
{
|
||||||
|
int itemIndex;
|
||||||
|
int quantity;
|
||||||
|
auto activeItems = filterActiveItems(inventoryItems);
|
||||||
|
int activeSize = activeItems.getSize();
|
||||||
|
if (activeSize == 0)
|
||||||
|
{
|
||||||
|
std::cout << "No active items available in Inventory" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
displayInventoryWithItems(activeItems);
|
||||||
|
std::cout << "Enter the index of the item to update: ";
|
||||||
|
util::read(itemIndex);
|
||||||
|
if (itemIndex < 1 || itemIndex > activeSize)
|
||||||
|
{
|
||||||
|
std::cout << "Invalid index selected." << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::cout << "Enter quantity to add: ";
|
||||||
|
util::read(quantity);
|
||||||
|
if (quantity < 0)
|
||||||
|
{
|
||||||
|
std::cout << "The quantity should be Greater than 0." << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const InventoryItem* selectedItem = activeItems.getValueAt(itemIndex - 1);
|
||||||
|
if (selectedItem != nullptr)
|
||||||
|
{
|
||||||
|
std::string selectedItemId = selectedItem->getId();
|
||||||
|
m_controller.addInventoryItemStock(selectedItemId, quantity);
|
||||||
|
std::cout << "Updated " << selectedItem->getPartName()
|
||||||
|
<< " stock. New quantity: " << selectedItem->getQuantity()
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Error: Selected item could not be found." << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: addInventoryItem
|
||||||
|
Description: Allows the admin to either add a new inventory item
|
||||||
|
or increase the quantity of an existing item.
|
||||||
|
Parameter: None
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
void AdminMenu::addInventoryItem()
|
void AdminMenu::addInventoryItem()
|
||||||
{
|
{
|
||||||
|
util::clear();
|
||||||
|
int choice, quantity;
|
||||||
|
double price;
|
||||||
|
std::string partName;
|
||||||
|
std::cout << "1. Add new item \n2. Add Quantity\nEnter your choice : ";
|
||||||
|
util::read(choice);
|
||||||
|
switch (choice)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::cout << "--------Enter Item Details----------\n";
|
||||||
|
std::cout << "Part Name : ";
|
||||||
|
util::read(partName);
|
||||||
|
std::cout << "Quantity : ";
|
||||||
|
util::read(quantity);
|
||||||
|
std::cout << "Price : ";
|
||||||
|
util::read(price);
|
||||||
|
m_controller.addInventoryItem(partName, quantity, price);
|
||||||
|
std::cout << "New Item " << partName << " added to the Inventory.\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
auto inventoryItems = m_controller.getInventoryItems();
|
||||||
|
addQuantityToItem(inventoryItems, m_controller);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
util::pressEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: removeInventoryItem
|
||||||
|
Description: Removes an active inventory item by marking it inactive
|
||||||
|
after user selection.
|
||||||
|
Parameter: None
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
void AdminMenu::removeInventoryItem()
|
void AdminMenu::removeInventoryItem()
|
||||||
{
|
{
|
||||||
|
util::clear();
|
||||||
|
auto inventoryItems = m_controller.getInventoryItems();
|
||||||
|
auto activeItems = filterActiveItems(inventoryItems);
|
||||||
|
int activeItemsSize = activeItems.getSize();
|
||||||
|
if (activeItemsSize == 0)
|
||||||
|
{
|
||||||
|
std::cout << "No items available in Inventory." << std::endl;
|
||||||
|
util::pressEnter();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
displayInventoryWithItems(activeItems);
|
||||||
|
int itemIndex;
|
||||||
|
std::cout << "Enter the index of the item to remove: ";
|
||||||
|
util::read(itemIndex);
|
||||||
|
if (itemIndex < 1 || itemIndex > activeItemsSize)
|
||||||
|
{
|
||||||
|
std::cout << "Invalid index selected." << std::endl;
|
||||||
|
util::pressEnter();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const InventoryItem* selectedItem = inventoryItems.getValueAt(itemIndex - 1);
|
||||||
|
if (selectedItem != nullptr)
|
||||||
|
{
|
||||||
|
if(selectedItem->getState() != util::State::INACTIVE)
|
||||||
|
{
|
||||||
|
std::string selectedItemId = selectedItem->getId();
|
||||||
|
m_controller.removeInventoryItem(selectedItemId);
|
||||||
|
std::cout << "Item " << selectedItem->getPartName() << " removed successfully." << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
util::pressEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: checkStockAvailability
|
||||||
|
Description: Checks if a specific inventory item is available
|
||||||
|
and displays its details if active.
|
||||||
|
Parameter: None
|
||||||
|
Return type: void
|
||||||
|
*/
|
||||||
void AdminMenu::checkStockAvailability()
|
void AdminMenu::checkStockAvailability()
|
||||||
{
|
{
|
||||||
|
util::clear();
|
||||||
|
std::string itemId;
|
||||||
|
std::cout << "Enter the Item Id : ";
|
||||||
|
util::read(itemId);
|
||||||
|
const InventoryItem* selectedItem = m_controller.getInventoryItem(itemId);
|
||||||
|
if (selectedItem != nullptr)
|
||||||
|
{
|
||||||
|
if (selectedItem->getState() != util::State::INACTIVE)
|
||||||
|
{
|
||||||
|
std::cout << "Item Details\n";
|
||||||
|
std::cout << "---------------------------------------------\n";
|
||||||
|
std::cout << "Item ID : " << selectedItem->getId() << "\n";
|
||||||
|
std::cout << "Part Name : " << selectedItem->getPartName() << "\n";
|
||||||
|
std::cout << "Quantity : " << selectedItem->getQuantity() << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
util::pressEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminMenu::assignJob()
|
void AdminMenu::assignJob()
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
File: AdminMenu.h
|
||||||
|
Description: Header file declaring the AdminMenu class, which provides
|
||||||
|
administrative operations such as inventory management,
|
||||||
|
user management, service configuration, and notifications.
|
||||||
|
Author: Trenser
|
||||||
|
Date:19-May-2026
|
||||||
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,335 +1,54 @@
|
|||||||
/*
|
|
||||||
File: CustomerMenu.cpp
|
|
||||||
Description: Implementation file containing the method definitions of the
|
|
||||||
CustomerMenu class, including menu handling, service selection,
|
|
||||||
combo package booking, profile updates, and password management.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#include <iomanip>
|
|
||||||
#include "CustomerMenu.h"
|
#include "CustomerMenu.h"
|
||||||
#include "Service.h"
|
|
||||||
#include "InventoryItem.h"
|
|
||||||
#include "ComboPackage.h"
|
|
||||||
#include "Service.h"
|
|
||||||
#include "InputHelper.h"
|
#include "InputHelper.h"
|
||||||
#include "OutputHelper.h"
|
#include "OutputHelper.h"
|
||||||
#include "Validator.h"
|
|
||||||
#include "Vector.h"
|
|
||||||
#include "Utility.h"
|
|
||||||
#include "Map.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: showMenu
|
|
||||||
Description: Displays the customer menu and handles user input until logout is selected.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void CustomerMenu::showMenu()
|
void CustomerMenu::showMenu()
|
||||||
{
|
{
|
||||||
while (true)
|
bool isMenuActive = true;
|
||||||
{
|
while (isMenuActive)
|
||||||
try
|
{
|
||||||
{
|
try
|
||||||
int choice;
|
{
|
||||||
util::clear();
|
int choice;
|
||||||
std::cout << "Customer Menu"
|
util::clear();
|
||||||
<< "\n1. Select a service"
|
std::cout << "" << std::endl;
|
||||||
<< "\n2. Select a combo package"
|
util::read(choice);
|
||||||
<< "\n3. Update Profile"
|
if (!handleOperation(choice))
|
||||||
<< "\n4. Change Password"
|
{
|
||||||
<< "\n5. View Service History"
|
isMenuActive = false;
|
||||||
<< "\n6. Complete Payments"
|
}
|
||||||
<< "\n7. View Invoices"
|
}
|
||||||
<< "\n8. View Notifications"
|
catch (const std::exception& e)
|
||||||
<< "\n9. Configure Notifications"
|
{
|
||||||
<< "\n10. Logout"
|
std::cout << "Exception: " << e.what() << std::endl;
|
||||||
<< "\nEnter a choice: ";
|
util::pressEnter();
|
||||||
util::read(choice);
|
}
|
||||||
if (!handleOperation(choice))
|
}
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (const std::exception& e)
|
|
||||||
{
|
|
||||||
std::cout << "Exception: " << e.what() << std::endl;
|
|
||||||
util::pressEnter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: handleOperation
|
|
||||||
Description: Executes the corresponding customer operation based on the selected menu choice.
|
|
||||||
Parameter: int choice - selected menu option
|
|
||||||
Return type: bool - true if menu continues, false if logout
|
|
||||||
*/
|
|
||||||
bool CustomerMenu::handleOperation(int choice)
|
bool CustomerMenu::handleOperation(int choice)
|
||||||
{
|
{
|
||||||
switch (choice)
|
return false;
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
selectService();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
selectComboPackage();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
updateDetails();
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
changePassword();
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
viewServiceHistory();
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
completePayments();
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
viewInvoices();
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
viewNotifications();
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
configureNotifications();
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
logout();
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
std::cout << "Enter a valid choice!" << std::endl;
|
|
||||||
util::pressEnter();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: logout
|
|
||||||
Description: Logs out the currently authenticated customer user.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void CustomerMenu::logout()
|
void CustomerMenu::logout()
|
||||||
{
|
{
|
||||||
m_controller.logout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: changePassword
|
|
||||||
Description: Allows the customer to change their password after validation.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void CustomerMenu::changePassword()
|
void CustomerMenu::changePassword()
|
||||||
{
|
{
|
||||||
std::string newPassword;
|
|
||||||
util::clear();
|
|
||||||
std::cout << "Enter new password: ";
|
|
||||||
util::read(newPassword);
|
|
||||||
m_controller.changePassword(newPassword);
|
|
||||||
if (!util::isPasswordValid(newPassword))
|
|
||||||
{
|
|
||||||
std::cout << "Error: Password is not strong enough!";
|
|
||||||
util::pressEnter();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::cout << "Password changed successfully";
|
|
||||||
util::pressEnter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: updateDetails
|
|
||||||
Description: Allows the customer to update their email and phone number after validation.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void CustomerMenu::updateDetails()
|
void CustomerMenu::updateDetails()
|
||||||
{
|
{
|
||||||
std::string email, phone;
|
|
||||||
util::clear();
|
|
||||||
std::cout << "Enter new email: ";
|
|
||||||
util::read(email);
|
|
||||||
if (!util::isEmailValid(email))
|
|
||||||
{
|
|
||||||
std::cout << "Error: Email is invalid!";
|
|
||||||
util::pressEnter();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::cout << "Enter new phone: ";
|
|
||||||
util::read(phone);
|
|
||||||
if (!util::isPhoneNumberValid(phone))
|
|
||||||
{
|
|
||||||
std::cout << "Error: Phone number is invalid!";
|
|
||||||
util::pressEnter();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_controller.updateUserDetails(email, phone);
|
|
||||||
std::cout << "Profile details updated successfully";
|
|
||||||
util::pressEnter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: selectServiceFromServices
|
|
||||||
Description: Displays active services and allows the customer to select one by index.
|
|
||||||
Parameter: const util::Map<std::string, const Service*>& services - list of services
|
|
||||||
Return type: const Service* - selected service
|
|
||||||
*/
|
|
||||||
static const Service* selectServiceFromServices(const util::Map<std::string, const Service*>& services)
|
|
||||||
{
|
|
||||||
util::Map<int, const Service*> activeServicesMap;
|
|
||||||
int currentIndex = 1;
|
|
||||||
int userInputIndex;
|
|
||||||
std::cout << std::left
|
|
||||||
<< std::setw(10) << "Index"
|
|
||||||
<< std::setw(15) << "Service ID"
|
|
||||||
<< std::setw(25) << "Service Name"
|
|
||||||
<< std::setw(15) << "Estimated Cost"
|
|
||||||
<< std::endl;
|
|
||||||
for (int index = 0; index < services.getSize(); index++)
|
|
||||||
{
|
|
||||||
const Service* currentService = services.getValueAt(index);
|
|
||||||
if (currentService->getState() != util::State::ACTIVE)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
activeServicesMap.insert(currentIndex, currentService);
|
|
||||||
double partsCost = calculatePartsCost(currentService);
|
|
||||||
std::cout << std::left
|
|
||||||
<< std::setw(10) << currentIndex
|
|
||||||
<< std::setw(15) << currentService->getId()
|
|
||||||
<< std::setw(25) << currentService->getName()
|
|
||||||
<< std::setw(15) << (currentService->getLaborCost() + partsCost)
|
|
||||||
<< std::endl;
|
|
||||||
currentIndex++;
|
|
||||||
}
|
|
||||||
if (activeServicesMap.getSize() == 0)
|
|
||||||
{
|
|
||||||
std::cout << "No active services available." << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
std::cout << "Enter service index: ";
|
|
||||||
util::read(userInputIndex);
|
|
||||||
if (activeServicesMap.find(userInputIndex) == -1)
|
|
||||||
{
|
|
||||||
std::cout << "Invalid service index." << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return activeServicesMap[userInputIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: selectService
|
|
||||||
Description: Allows the customer to select a service, provide vehicle details,
|
|
||||||
and book the service through the controller.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void CustomerMenu::selectService()
|
void CustomerMenu::selectService()
|
||||||
{
|
{
|
||||||
std::string vehicleNumber, vehicleBrand, vehicleModel;
|
|
||||||
auto services = m_controller.getServices();
|
|
||||||
util::Vector<std::string> selectedServices;
|
|
||||||
util::clear();
|
|
||||||
const Service* selectedService = selectServiceFromServices(services);
|
|
||||||
if (selectedService == nullptr)
|
|
||||||
{
|
|
||||||
std::cout << "Failed to book service!";
|
|
||||||
util::pressEnter();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedServices.push_back(selectedService->getId());
|
|
||||||
util::clear();
|
|
||||||
std::cout << "Enter vehicle number: ";
|
|
||||||
util::read(vehicleNumber);
|
|
||||||
std::cout << "Enter vehicle brand: ";
|
|
||||||
util::read(vehicleBrand);
|
|
||||||
std::cout << "Enter vehicle model: ";
|
|
||||||
util::read(vehicleModel);
|
|
||||||
m_controller.purchaseService(selectedServices, vehicleNumber, vehicleBrand, vehicleModel);
|
|
||||||
std::cout << "Service has been booked successfully";
|
|
||||||
util::pressEnter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: selectComboPackageFromPackages
|
|
||||||
Description: Displays active combo packages and allows the customer to select one by index.
|
|
||||||
Parameter: const util::Map<std::string, const ComboPackage*>& comboPackages - list of combo packages
|
|
||||||
Return type: const ComboPackage* - selected combo package
|
|
||||||
*/
|
|
||||||
static const ComboPackage* selectComboPackageFromPackages(const util::Map<std::string, const ComboPackage*>& comboPackages)
|
|
||||||
{
|
|
||||||
util::Map<int, const ComboPackage*> activeComboPackages;
|
|
||||||
int currentIndex = 1;
|
|
||||||
int userInputIndex;
|
|
||||||
std::cout << std::left
|
|
||||||
<< std::setw(10) << "Index"
|
|
||||||
<< std::setw(15) << "Combo Package ID"
|
|
||||||
<< std::setw(15) << "Combo Package Name"
|
|
||||||
<< std::setw(15) << "Estimate Cost"
|
|
||||||
<< std::endl;
|
|
||||||
for (int index = 0; index < comboPackages.getSize(); index++)
|
|
||||||
{
|
|
||||||
const ComboPackage* currentComboPackage = comboPackages.getValueAt(index);
|
|
||||||
if (currentComboPackage->getState() != util::State::ACTIVE)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
activeComboPackages.insert(currentIndex, currentComboPackage);
|
|
||||||
std::cout << std::left
|
|
||||||
<< std::setw(10) << currentIndex
|
|
||||||
<< std::setw(15) << currentComboPackage->getId()
|
|
||||||
<< std::setw(25) << currentComboPackage->getPackageName()
|
|
||||||
<< std::setw(15) << calculateComboServiceEstimatedCost(currentComboPackage)
|
|
||||||
<< std::endl;
|
|
||||||
currentIndex++;
|
|
||||||
}
|
|
||||||
if (activeComboPackages.getSize() == 0)
|
|
||||||
{
|
|
||||||
std::cout << "No active combo packages available." << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
std::cout << "Enter combo package index: ";
|
|
||||||
util::read(userInputIndex);
|
|
||||||
if (activeComboPackages.find(userInputIndex) == -1)
|
|
||||||
{
|
|
||||||
std::cout << "Invalid combo package index." << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return activeComboPackages[userInputIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: selectComboPackage
|
|
||||||
Description: Allows the customer to select a combo package, provide vehicle details,
|
|
||||||
and book the package through the controller.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void CustomerMenu::selectComboPackage()
|
void CustomerMenu::selectComboPackage()
|
||||||
{
|
{
|
||||||
std::string vehicleNumber, vehicleBrand, vehicleModel;
|
|
||||||
auto comboPackages = m_controller.getComboPackages();
|
|
||||||
util::clear();
|
|
||||||
const ComboPackage* selectedComboPackage = selectComboPackageFromPackages(comboPackages);
|
|
||||||
if (selectedComboPackage == nullptr)
|
|
||||||
{
|
|
||||||
std::cout << "Failed to book combo package!";
|
|
||||||
util::pressEnter();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
util::clear();
|
|
||||||
std::cout << "Enter vehicle number: ";
|
|
||||||
util::read(vehicleNumber);
|
|
||||||
std::cout << "Enter vehicle brand: ";
|
|
||||||
util::read(vehicleBrand);
|
|
||||||
std::cout << "Enter vehicle model: ";
|
|
||||||
util::read(vehicleModel);
|
|
||||||
m_controller.purchaseComboPackage(selectedComboPackage->getId(), vehicleNumber, vehicleBrand, vehicleModel);
|
|
||||||
std::cout << "Combo Package has been booked successfully";
|
|
||||||
util::pressEnter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomerMenu::viewServiceHistory()
|
void CustomerMenu::viewServiceHistory()
|
||||||
|
|||||||
@@ -1,12 +1,3 @@
|
|||||||
/*
|
|
||||||
File: CustomerMenu.h
|
|
||||||
Description: Header file declaring the CustomerMenu class, which provides
|
|
||||||
customer operations such as selecting services, booking combo
|
|
||||||
packages, updating profile details, managing payments, viewing
|
|
||||||
invoices, and configuring notifications.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
File: MenuHelper.h
|
|
||||||
Description: Header file declaring the MenuHelper class, which provides
|
|
||||||
utility functions for menu-driven operations such as
|
|
||||||
notification selection and display.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
#include <iomanip>
|
|
||||||
#include "Notification.h"
|
|
||||||
#include "Map.h"
|
|
||||||
#include "InputHelper.h"
|
|
||||||
#include "OutputHelper.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: selectNotification
|
|
||||||
Description: Displays a list of notifications with index, ID, title, and timestamp.
|
|
||||||
Allows the user to select a notification by index. Returns the selected
|
|
||||||
notification or nullptr if the selection is invalid.
|
|
||||||
Parameter: const util::Vector<const Notification*>& notifications - list of notifications
|
|
||||||
Return type: const Notification* - pointer to the selected notification
|
|
||||||
*/
|
|
||||||
inline const Notification* selectNotification(const util::Vector<const Notification*>& notifications)
|
|
||||||
{
|
|
||||||
if (notifications.getSize() == 0)
|
|
||||||
{
|
|
||||||
std::cout << "No notifications available." << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
std::cout << std::left
|
|
||||||
<< std::setw(6) << "Index"
|
|
||||||
<< std::setw(15) << "ID"
|
|
||||||
<< std::setw(30) << "Title"
|
|
||||||
<< std::setw(25) << "Timestamp"
|
|
||||||
<< std::endl;
|
|
||||||
int currentIndex = 1;
|
|
||||||
for (int iterator = 0; iterator < notifications.getSize(); iterator++)
|
|
||||||
{
|
|
||||||
const Notification* currentNotification = notifications[iterator];
|
|
||||||
if (currentNotification)
|
|
||||||
{
|
|
||||||
std::cout << std::left
|
|
||||||
<< std::setw(6) << currentIndex
|
|
||||||
<< std::setw(15) << currentNotification->getId()
|
|
||||||
<< std::setw(30) << currentNotification->getTitle()
|
|
||||||
<< std::setw(25) << currentNotification->getCreatedAt().toString()
|
|
||||||
<< std::endl;
|
|
||||||
currentIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int selectedIndex;
|
|
||||||
std::cout << "Select notification: ";
|
|
||||||
util::read(selectedIndex);
|
|
||||||
if (selectedIndex < 1 || selectedIndex > notifications.getSize())
|
|
||||||
{
|
|
||||||
std::cout << "Invalid selection." << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return notifications[selectedIndex - 1];
|
|
||||||
}
|
|
||||||
@@ -1,25 +1,7 @@
|
|||||||
/*
|
|
||||||
File: UserInterface.cpp
|
|
||||||
Description: Implementation file containing the method definitions of the
|
|
||||||
UserInterface class, including system run loop, login handling,
|
|
||||||
and customer registration logic.
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
#include "InputHelper.h"
|
#include "InputHelper.h"
|
||||||
#include "OutputHelper.h"
|
#include "OutputHelper.h"
|
||||||
#include "Enums.h"
|
|
||||||
#include "User.h"
|
|
||||||
#include "Validator.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
Function: run
|
|
||||||
Description: Runs the main system loop, displaying the initial menu for login,
|
|
||||||
customer registration, or exit. Handles exceptions gracefully.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void UserInterface::run()
|
void UserInterface::run()
|
||||||
{
|
{
|
||||||
bool isMenuActive = true;
|
bool isMenuActive = true;
|
||||||
@@ -44,12 +26,6 @@ void UserInterface::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: handleOperation
|
|
||||||
Description: Executes the corresponding system operation based on the selected menu choice.
|
|
||||||
Parameter: int choice - selected menu option
|
|
||||||
Return type: bool - true if menu continues, false if exit
|
|
||||||
*/
|
|
||||||
bool UserInterface::handleOperation(int choice)
|
bool UserInterface::handleOperation(int choice)
|
||||||
{
|
{
|
||||||
switch (choice)
|
switch (choice)
|
||||||
@@ -70,90 +46,12 @@ bool UserInterface::handleOperation(int choice)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: login
|
|
||||||
Description: Handles user login by validating credentials. Based on the authenticated
|
|
||||||
user type, navigates to the appropriate menu (Admin, Technician, Customer).
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void UserInterface::login()
|
void UserInterface::login()
|
||||||
{
|
{
|
||||||
std::string username, password;
|
|
||||||
util::clear();
|
|
||||||
std::cout << "Enter username: ";
|
|
||||||
util::read(username);
|
|
||||||
std::cout << "Enter password: ";
|
|
||||||
util::read(password);
|
|
||||||
if (m_controller.login(username, password))
|
|
||||||
{
|
|
||||||
const User* authenticatedUser = m_controller.getAuthenticatedUser();
|
|
||||||
if (authenticatedUser != nullptr)
|
|
||||||
{
|
|
||||||
switch (authenticatedUser->getUserType())
|
|
||||||
{
|
|
||||||
case util::UserType::ADMIN:
|
|
||||||
m_adminMenu.showMenu();
|
|
||||||
break;
|
|
||||||
case util::UserType::TECHNICIAN:
|
|
||||||
m_technicianMenu.showMenu();
|
|
||||||
break;
|
|
||||||
case util::UserType::CUSTOMER:
|
|
||||||
m_customerMenu.showMenu();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cout << "\nError: Unknown user type";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "\nError: Invalid Username or Password";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function: registerCustomer
|
|
||||||
Description: Registers a new customer by collecting and validating details such as
|
|
||||||
username, name, email, password, and phone number. Delegates creation
|
|
||||||
to the controller.
|
|
||||||
Parameter: None
|
|
||||||
Return type: void
|
|
||||||
*/
|
|
||||||
void UserInterface::registerCustomer()
|
void UserInterface::registerCustomer()
|
||||||
{
|
{
|
||||||
std::string username, name, email, phone, password;
|
|
||||||
util::clear();
|
|
||||||
std::cout << "Enter username: ";
|
|
||||||
util::read(username);
|
|
||||||
std::cout << "Enter name: ";
|
|
||||||
util::read(name);
|
|
||||||
std::cout << "Enter email: ";
|
|
||||||
util::read(email);
|
|
||||||
if (!util::isEmailValid(email))
|
|
||||||
{
|
|
||||||
std::cout << "Error: Email is invalid!";
|
|
||||||
util::pressEnter();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::cout << "Enter password: ";
|
|
||||||
util::read(password);
|
|
||||||
if (!util::isPasswordValid(password))
|
|
||||||
{
|
|
||||||
std::cout << "Error: Password is invalid!";
|
|
||||||
util::pressEnter();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::cout << "Enter phone: ";
|
|
||||||
util::read(phone);
|
|
||||||
if (!util::isPhoneNumberValid(phone))
|
|
||||||
{
|
|
||||||
std::cout << "Error: Phone number is invalid!";
|
|
||||||
util::pressEnter();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_controller.createCustomer(username, name, password, email, phone);
|
|
||||||
std::cout << "Registration is successful";
|
|
||||||
util::pressEnter();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,3 @@
|
|||||||
/*
|
|
||||||
File: UserInterface.h
|
|
||||||
Description: Header file declaring the UserInterface class, which provides
|
|
||||||
the main entry point for the Vehicle Service System. Handles
|
|
||||||
login, customer registration, and menu navigation for different
|
|
||||||
user roles (Admin, Technician, Customer).
|
|
||||||
Author: Trenser
|
|
||||||
Date:19-May-2026
|
|
||||||
*/
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
#include "AdminMenu.h"
|
#include "AdminMenu.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user