From fcdf7ba472926f209168c2044ec0aefd0bc4f7e0 Mon Sep 17 00:00:00 2001
From: Ida Made Revindra Dikta Mahendra <idamaderevindra05@gmail.com>
Date: Fri, 28 Mar 2025 09:32:29 +0700
Subject: [PATCH] [CHORE]: Edit Product service methods to call notify after
 create/delete

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

diff --git a/src/service/product.rs b/src/service/product.rs
index 87a55ac..9d761aa 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,8 @@ 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 +43,7 @@ impl ProductService {
         }
         let product: Product = product_opt.unwrap();
 
+        NotificationService.notify(&product.product_type, "DELETED", product.clone());
         return Ok(Json::from(product));
     }
 
-- 
GitLab