Merge branch 'feature-notification-management-not004' into feature-notification-management
This commit is contained in:
+2
@@ -171,11 +171,13 @@
|
|||||||
<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" />
|
||||||
|
|||||||
@@ -163,5 +163,6 @@ void Controller::configureNotifications(const std::string& userID, bool paymentN
|
|||||||
|
|
||||||
void Controller::runSystemChecks()
|
void Controller::runSystemChecks()
|
||||||
{
|
{
|
||||||
|
m_inventoryManagementService.sendLowStockAlerts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
#include "AuthenticationManagementService.h"
|
#include "AuthenticationManagementService.h"
|
||||||
#include "UserManagementService.h"
|
#include "UserManagementService.h"
|
||||||
|
#include "InventoryManagementService.h"
|
||||||
|
|
||||||
class Service;
|
class Service;
|
||||||
class ComboPackage;
|
class ComboPackage;
|
||||||
@@ -19,6 +20,7 @@ class Controller
|
|||||||
private:
|
private:
|
||||||
AuthenticationManagementService m_authenticationManagementService;
|
AuthenticationManagementService m_authenticationManagementService;
|
||||||
UserManagementService m_userManagementService;
|
UserManagementService m_userManagementService;
|
||||||
|
InventoryManagementService m_inventoryManagementService;
|
||||||
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();
|
||||||
|
|||||||
+49
@@ -1 +1,50 @@
|
|||||||
|
#include <stdexcept>
|
||||||
#include "InventoryManagementService.h"
|
#include "InventoryManagementService.h"
|
||||||
|
#include "Vector.h"
|
||||||
|
#include "Enums.h"
|
||||||
|
#include "InventoryItem.h"
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
static void sendLowStockAlertsToAdmins(InventoryManagementService& inventoryManagementService, const InventoryItem* inventoryItem, const util::Vector<User*>& adminUsers)
|
||||||
|
{
|
||||||
|
int adminUsersSize = adminUsers.getSize();
|
||||||
|
for (int index = 0; index < adminUsersSize; index++)
|
||||||
|
{
|
||||||
|
inventoryManagementService.sendNotification(
|
||||||
|
adminUsers[index],
|
||||||
|
"Low Stock Alert",
|
||||||
|
"The inventory item with ID " + inventoryItem->getId() +
|
||||||
|
" has very low quantity in the inventory"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InventoryManagementService::sendLowStockAlerts()
|
||||||
|
{
|
||||||
|
auto& inventoryItems = m_dataStore.getInventoryItems();
|
||||||
|
int inventoryItemsSize = inventoryItems.getSize();
|
||||||
|
auto& usersMap = m_dataStore.getUsers();
|
||||||
|
int usersMapSize = usersMap.getSize();
|
||||||
|
util::Vector<User*> adminUsers;
|
||||||
|
for (int index = 0; index < usersMapSize; index++)
|
||||||
|
{
|
||||||
|
User* user = usersMap.getValueAt(index);
|
||||||
|
if (user->getUserType() == util::UserType::ADMIN)
|
||||||
|
{
|
||||||
|
adminUsers.push_back(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int adminUsersSize = adminUsers.getSize();
|
||||||
|
if (adminUsersSize < 1)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("The system has no admins present!");
|
||||||
|
}
|
||||||
|
for (int index = 0; index <= inventoryItemsSize; index++)
|
||||||
|
{
|
||||||
|
InventoryItem* inventoryItem = inventoryItems.getValueAt(index);
|
||||||
|
if (inventoryItem && inventoryItem->getQuantity() < config::threshold::INVENTORY_LOW_STOCK_THRESHOLD)
|
||||||
|
{
|
||||||
|
sendLowStockAlertsToAdmins(*this, inventoryItem, adminUsers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace config
|
||||||
|
{
|
||||||
|
namespace threshold
|
||||||
|
{
|
||||||
|
constexpr int INVENTORY_LOW_STOCK_THRESHOLD = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#pragma once
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
void UserInterface::run()
|
void UserInterface::run()
|
||||||
{
|
{
|
||||||
|
m_controller.runSystemChecks();
|
||||||
bool isMenuActive = true;
|
bool isMenuActive = true;
|
||||||
while (isMenuActive)
|
while (isMenuActive)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user