b230e3062c
<UserStory> ADM002: Remove Technician or Customer </UserStory>
<Changes>
1. Integrated UserManagementService and ServiceManagementService into Controller for user removal operations.
2. Added Controller::removeUser to validate user existence, cancel related service bookings and technician jobs, and mark user inactive.
3. Updated JobCard and ServiceBooking models to use util::ServiceJobStatus consistently and store technician references as User* instead of strings.
4. Extended util::ServiceJobStatus enum with PENDING and CANCELLED states, including string conversion support.
5. Implemented ServiceManagementService methods to cancel customer service bookings and technician jobs, with inventory restocking and notifications.
6. Enhanced AdminMenu::removeUser to list active users, validate index input, confirm deletion, and invoke Controller::removeUser.
7. Added helper functions in AdminMenu to filter active users and display them with formatted output including user type.
</Changes>
<Test>
Precondition:
1. Admin is logged into the system.
2. Technician accounts exist in the system.
3. Technician has active job assignments.
Steps:
1. Navigate to Admin Menu and select "Remove User".
2. System displays list of active users with IDs, usernames, and user types.
- Verify that inactive users are excluded from the list.
3. Admin selects technician ID for removal.
- Verify that system confirms deletion before proceeding.
4. Technician is removed from job assignment list.
- Verify that associated jobs are cancelled, inventory is restocked, and notifications are sent.
</Test>
<Review>
Sreeja Reghukumar
</Review>
184 lines
4.0 KiB
C++
184 lines
4.0 KiB
C++
#pragma once
|
|
#include <stdexcept>
|
|
|
|
namespace util
|
|
{
|
|
enum class UserType
|
|
{
|
|
ADMIN,
|
|
TECHNICIAN,
|
|
CUSTOMER
|
|
};
|
|
|
|
enum class PaymentMode
|
|
{
|
|
ONLINE,
|
|
OFFLINE
|
|
};
|
|
|
|
enum class PaymentStatus
|
|
{
|
|
PENDING,
|
|
COMPLETED
|
|
};
|
|
|
|
enum class ServiceJobStatus
|
|
{
|
|
PENDING,
|
|
STARTED,
|
|
COMPLETED,
|
|
CANCELLED
|
|
};
|
|
|
|
enum class State
|
|
{
|
|
ACTIVE,
|
|
INACTIVE
|
|
};
|
|
|
|
inline std::string getUserTypeString(UserType type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case UserType::ADMIN:
|
|
return "ADMIN";
|
|
case UserType::TECHNICIAN:
|
|
return "TECHNICIAN";
|
|
case UserType::CUSTOMER:
|
|
return "CUSTOMER";
|
|
}
|
|
throw std::invalid_argument("Invalid UserType");
|
|
}
|
|
|
|
inline UserType getUserType(const std::string& value)
|
|
{
|
|
if (value == "ADMIN")
|
|
{
|
|
return UserType::ADMIN;
|
|
}
|
|
if (value == "TECHNICIAN")
|
|
{
|
|
return UserType::TECHNICIAN;
|
|
}
|
|
if (value == "CUSTOMER")
|
|
{
|
|
return UserType::CUSTOMER;
|
|
}
|
|
throw std::invalid_argument("Invalid UserType string");
|
|
}
|
|
|
|
inline std::string getPaymentModeString(PaymentMode mode)
|
|
{
|
|
switch (mode)
|
|
{
|
|
case PaymentMode::ONLINE:
|
|
return "ONLINE";
|
|
case PaymentMode::OFFLINE:
|
|
return "OFFLINE";
|
|
}
|
|
throw std::invalid_argument("Invalid PaymentMode");
|
|
}
|
|
|
|
inline PaymentMode getPaymentMode(const std::string& value)
|
|
{
|
|
if (value == "ONLINE")
|
|
{
|
|
return PaymentMode::ONLINE;
|
|
}
|
|
if (value == "OFFLINE")
|
|
{
|
|
return PaymentMode::OFFLINE;
|
|
}
|
|
throw std::invalid_argument("Invalid PaymentMode string");
|
|
}
|
|
|
|
inline std::string getPaymentStatusString(PaymentStatus status)
|
|
{
|
|
switch (status)
|
|
{
|
|
case PaymentStatus::PENDING:
|
|
return "PENDING";
|
|
case PaymentStatus::COMPLETED:
|
|
return "COMPLETED";
|
|
}
|
|
throw std::invalid_argument("Invalid PaymentStatus");
|
|
}
|
|
|
|
inline PaymentStatus getPaymentStatus(const std::string& value)
|
|
{
|
|
if (value == "PENDING")
|
|
{
|
|
return PaymentStatus::PENDING;
|
|
}
|
|
|
|
if (value == "COMPLETED")
|
|
{
|
|
return PaymentStatus::COMPLETED;
|
|
}
|
|
|
|
throw std::invalid_argument("Invalid PaymentStatus string");
|
|
}
|
|
|
|
inline std::string getServiceJobStatusString(ServiceJobStatus status)
|
|
{
|
|
switch (status)
|
|
{
|
|
case ServiceJobStatus::PENDING:
|
|
return "PENDING";
|
|
case ServiceJobStatus::STARTED:
|
|
return "STARTED";
|
|
case ServiceJobStatus::COMPLETED:
|
|
return "COMPLETED";
|
|
case ServiceJobStatus::CANCELLED:
|
|
return "CANCELLED";
|
|
}
|
|
throw std::invalid_argument("Invalid ServiceJobStatus");
|
|
}
|
|
|
|
inline ServiceJobStatus getServiceJobStatus(const std::string& value)
|
|
{
|
|
if (value == "STARTED")
|
|
{
|
|
return ServiceJobStatus::STARTED;
|
|
}
|
|
if (value == "COMPLETED")
|
|
{
|
|
return ServiceJobStatus::COMPLETED;
|
|
}
|
|
if (value == "PENDING")
|
|
{
|
|
return ServiceJobStatus::PENDING;
|
|
}
|
|
if (value == "CANCELLED")
|
|
{
|
|
return ServiceJobStatus::CANCELLED;
|
|
}
|
|
throw std::invalid_argument("Invalid ServiceJobStatus string");
|
|
}
|
|
|
|
inline std::string getStateString(State status)
|
|
{
|
|
switch (status)
|
|
{
|
|
case State::ACTIVE:
|
|
return "STARTED";
|
|
case State::INACTIVE:
|
|
return "COMPLETED";
|
|
}
|
|
throw std::invalid_argument("Invalid State");
|
|
}
|
|
|
|
inline State getState(const std::string& value)
|
|
{
|
|
if (value == "ACTIVE")
|
|
{
|
|
return State::ACTIVE;
|
|
}
|
|
if (value == "COMPLETED")
|
|
{
|
|
return State::INACTIVE;
|
|
}
|
|
throw std::invalid_argument("Invalid State string");
|
|
}
|
|
}
|