From dabf68f404bc7060b2170799e377a91f8c9e4ac5 Mon Sep 17 00:00:00 2001
From: Scallss <pascalhafidz2005@gmail.com>
Date: Fri, 28 Mar 2025 16:40:34 +0700
Subject: [PATCH] Edit Product service methods to call notify after
 create/delete.

---
 src/service/product.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/service/product.rs b/src/service/product.rs
index 443b7fa..32b378a 100644
--- a/src/service/product.rs
+++ b/src/service/product.rs
@@ -4,6 +4,7 @@ use rocket::serde::json::Json;
 use bambangshop::{Result, compose_error_response};
 use crate::model::product::Product;
 use crate::repository::product::ProductRepository;
+use crate::service::notification::NotificationService;
 
 pub struct ProductService;
 
@@ -12,6 +13,7 @@ impl ProductService {
         product.product_type = product.product_type.to_uppercase();
         let product_result: Product = ProductRepository::add(product);
 
+        NotificationService.notify(&product_result.product_type, "CREATED", product_result.clone());
         return Ok(product_result);
     }
 
@@ -40,6 +42,7 @@ impl ProductService {
         }
         let product: Product = product_opt.unwrap();
 
+        NotificationService.notify(&product.product_type, "DELETED", product.clone());
         return Ok(Json::from(product));
     }
 
@@ -53,7 +56,7 @@ impl ProductService {
         }
         let product: Product = product_opt.unwrap();
 
-        NotificationService::notify(&product.product_type, "PROMOTION", product.clone());
+        NotificationService.notify(&product.product_type, "PROMOTION", product.clone());
         return Ok(product);
     }
 }
-- 
GitLab