From 80b91f3f1bb4573bdcd98a9825487f10745f1160 Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Tue, 26 May 2026 18:48:23 +0530 Subject: [PATCH] Fix View Service History and View Notification Issue - Updated sendNotification in InventoryManagementService, PaymentManagementService, and ServiceManagementService to use only the provided title instead of prefixing with service name. - Added "View Service History" header in CustomerMenu::viewServiceHistory for clarity. - Adjusted column widths in service history table for better alignment: - Booking ID column widened to 15. - Vehicle Brand, Vehicle Number, Vehicle Model, Discount %, and Status columns widened to 20. - Updated output formatting in CustomerMenu::viewServiceHistory to match new widths. - Added "View and Delete Notification" header in MenuHelper::viewAndDeleteNotification for clarity. - Moved empty notification validation from selectNotification to viewAndDeleteNotification: - Displays "No notifications available." message. - Added util::pressEnter() prompt before returning when no notifications exist. - Increased Notification title column width from 30 to 35 in selectNotification for improved readability. Fixes #1748 --- .../services/InventoryManagementService.cpp | 2 +- .../services/PaymentManagementService.cpp | 2 +- .../services/ServiceManagementService.cpp | 2 +- .../views/CustomerMenu.cpp | 25 ++++++++++--------- .../views/MenuHelper.h | 14 ++++++----- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp index 5c3327a..d08d957 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/InventoryManagementService.cpp @@ -323,7 +323,7 @@ void InventoryManagementService::sendNotification(User* user, const std::string& Factory::getObject( user->getId(), user, - "InventoryManagementService: " + title, + title, message, util::Timestamp() ); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp index ba3282a..80e167d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/PaymentManagementService.cpp @@ -86,7 +86,7 @@ void PaymentManagementService::sendNotification(User* user, const std::string& t Factory::getObject( user->getId(), user, - "PaymentManagementService: " + title, + title, message, util::Timestamp() ); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp index 799d701..45c6fe4 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/ServiceManagementService.cpp @@ -175,7 +175,7 @@ void ServiceManagementService::sendNotification(User* user, const std::string& t Factory::getObject( user->getId(), user, - "ServiceManagementService: " + title, + title, message, util::Timestamp() ); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 85e7021..c8d334d 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -260,16 +260,17 @@ void CustomerMenu::viewServiceHistory() const User* currentUser = m_controller.getAuthenticatedUser(); std::string currentUserID = currentUser->getId(); util::Map serviceBookingsByCurrentUser = m_controller.getServiceBookingsByUser(currentUserID); + std::cout << "View Service History" << std::endl; if (serviceBookingsByCurrentUser.getSize() != 0) { std::cout << std::left - << std::setw(12) << "Booking ID" + << std::setw(15) << "Booking ID" << std::setw(20) << "Technician" - << std::setw(15) << "Vehicle Brand" - << std::setw(15) << "Vehicle Number" - << std::setw(15) << "Vehicle Model" - << std::setw(10) << "Discount %" - << std::setw(12) << "Status" + << std::setw(20) << "Vehicle Brand" + << std::setw(20) << "Vehicle Number" + << std::setw(20) << "Vehicle Model" + << std::setw(20) << "Discount %" + << std::setw(20) << "Status" << std::endl; for (int iterator = 0; iterator < serviceBookingsByCurrentUser.getSize(); iterator++) { @@ -278,13 +279,13 @@ void CustomerMenu::viewServiceHistory() ? "Not Assigned" : currentBooking->getAssignedTechnician()->getName(); std::cout << std::left - << std::setw(12) << currentBooking->getId() + << std::setw(15) << currentBooking->getId() << std::setw(20) << technicianName - << std::setw(15) << currentBooking->getVehicleBrand() - << std::setw(15) << currentBooking->getVehicleNumber() - << std::setw(15) << currentBooking->getVehicleModel() - << std::setw(10) << currentBooking->getDiscountPercentage() - << std::setw(12) << util::getServiceJobStatusString(currentBooking->getStatus()) + << std::setw(20) << currentBooking->getVehicleBrand() + << std::setw(20) << currentBooking->getVehicleNumber() + << std::setw(20) << currentBooking->getVehicleModel() + << std::setw(20) << currentBooking->getDiscountPercentage() + << std::setw(20) << util::getServiceJobStatusString(currentBooking->getStatus()) << std::endl; hasServiceHistory = true; } diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h index 17b9bc5..462391b 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -529,11 +529,6 @@ Return type: const Notification* - pointer to the selected notification */ inline const Notification* selectNotification(const util::Vector& notifications) { - if (notifications.getSize() == 0) - { - std::cout << "No notifications available." << std::endl; - return nullptr; - } util::Map indexedNotifications; std::cout << std::left << std::setw(6) << "Index" @@ -550,7 +545,7 @@ inline const Notification* selectNotification(const util::VectorgetId() - << std::setw(30) << currentNotification->getTitle() + << std::setw(35) << currentNotification->getTitle() << std::setw(25) << currentNotification->getCreatedAt().toString() << std::endl; indexedNotifications.insert(currentIndex, currentNotification); @@ -603,6 +598,13 @@ inline void viewAndDeleteNotification(Controller& controller) { util::clear(); auto notifications = controller.getNotifications(); + std::cout << "View and Delete Notification" << std::endl; + if (notifications.getSize() == 0) + { + std::cout << "No notifications available." << std::endl; + util::pressEnter(); + return; + } const Notification* selectedNotification = selectNotification(notifications); if (!selectedNotification) {