Setup codebase
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
#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
|
||||
{
|
||||
STARTED,
|
||||
COMPLETED
|
||||
};
|
||||
|
||||
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::STARTED:
|
||||
return "STARTED";
|
||||
case ServiceJobStatus::COMPLETED:
|
||||
return "COMPLETED";
|
||||
}
|
||||
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;
|
||||
}
|
||||
throw std::invalid_argument("Invalid ServiceJobStatus string");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user