Implement Add Technician Functionality
<UserStory> ADM001: Add Technician </UserStory>
<Changes>
1. Added UserManagementService integration in Controller to support technician account creation.
2. Updated Controller::createTechnician method to call createUser with util::UserType::TECHNICIAN.
3. Renamed parameter from 'phone' to 'phoneNumber' for clarity and consistency.
4. Enhanced AdminMenu::addTechnician with input validation for password, email, and phone number.
5. Added success and error handling messages in AdminMenu for technician creation workflow.
</Changes>
<Test>
Precondition:
1. Admin is logged into the system.
2. UserManagementService is available and connected.
3. No existing technician account with the same username/email.
Steps:
1. Navigate to Admin Menu and select "Add Technician".
2. Enter technician details (username, password, email, phone number).
- Verify that invalid password/email/phone inputs are rejected with error messages.
3. Enter valid technician details.
- Verify that uniqueness is checked and duplicate accounts are not created.
4. Submit valid details.
- Verify that technician account is created successfully and confirmation message is displayed.
</Test>
<Review>
Sreeja Reghukumar
</Review>
This commit is contained in:
+2
-1
@@ -22,8 +22,9 @@ const User* Controller::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& phoneNumber)
|
||||
{
|
||||
m_userManagementService.createUser(username, password, email, phoneNumber, util::UserType::TECHNICIAN);
|
||||
}
|
||||
|
||||
void Controller::updateUserDetails(const std::string& email, const std::string& phone)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Map.h"
|
||||
#include <string>
|
||||
#include "Enums.h"
|
||||
#include "UserManagementService.h"
|
||||
|
||||
class Service;
|
||||
class ComboPackage;
|
||||
@@ -14,13 +15,15 @@ class Notification;
|
||||
|
||||
class Controller
|
||||
{
|
||||
private:
|
||||
UserManagementService m_userManagementService;
|
||||
public:
|
||||
bool login(const std::string& username, const std::string& password);
|
||||
void logout();
|
||||
void changePassword(const std::string& newPassword);
|
||||
void createCustomer(const std::string& username, const std::string& password, const std::string& email, const std::string& phone);
|
||||
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& phoneNumber);
|
||||
void updateUserDetails(const std::string& email, const std::string& phone);
|
||||
util::Map<std::string, const Service*> getServices();
|
||||
util::Map<std::string, const ComboPackage*> getComboPackages();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <iomanip>
|
||||
#include "AdminMenu.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "Validator.h"
|
||||
|
||||
void AdminMenu::showMenu()
|
||||
{
|
||||
@@ -70,6 +72,37 @@ void AdminMenu::removeService()
|
||||
|
||||
void AdminMenu::addTechnician()
|
||||
{
|
||||
util::clear();
|
||||
std::string username, password, email, phoneNumber;
|
||||
std::cout << std::left << std::setw(25) << "Enter Technician Username:";
|
||||
util::read(username);
|
||||
std::cout << std::setw(25) << "Enter Technician Password:";
|
||||
util::read(password);
|
||||
if(!util::isPasswordValid(password))
|
||||
{
|
||||
std::cout << "Error: Password is invalid!";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
std::cout << std::setw(25) << "Enter Technician Email:";
|
||||
util::read(email);
|
||||
if(!util::isEmailValid(email))
|
||||
{
|
||||
std::cout << "Error: Email is invalid!";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
std::cout << std::setw(25) << "Enter Technician Phone:";
|
||||
util::read(phoneNumber);
|
||||
if(!util::isPhoneNumberValid(phoneNumber))
|
||||
{
|
||||
std::cout << "Error: Phone Number is invalid!";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
m_controller.createTechnician(username, password, email, phoneNumber);
|
||||
std::cout << "\nTechnician Added Successfully.\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
|
||||
void AdminMenu::removeUser()
|
||||
|
||||
Reference in New Issue
Block a user