Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit fcdf7ba4 authored by Ida Made Revindra Dikta Mahendra's avatar Ida Made Revindra Dikta Mahendra
Browse files

[CHORE]: Edit Product service methods to call notify after create/delete

parent 0d7ab415
Branches
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ use rocket::serde::json::Json; ...@@ -4,6 +4,7 @@ use rocket::serde::json::Json;
use bambangshop::{Result, compose_error_response}; use bambangshop::{Result, compose_error_response};
use crate::model::product::Product; use crate::model::product::Product;
use crate::repository::product::ProductRepository; use crate::repository::product::ProductRepository;
use crate::service::notification::NotificationService;
pub struct ProductService; pub struct ProductService;
...@@ -12,6 +13,8 @@ impl ProductService { ...@@ -12,6 +13,8 @@ impl ProductService {
product.product_type = product.product_type.to_uppercase(); product.product_type = product.product_type.to_uppercase();
let product_result: Product = ProductRepository::add(product); let product_result: Product = ProductRepository::add(product);
NotificationService.notify(&product_result.product_type, "CREATED",
product_result.clone());
return Ok(product_result); return Ok(product_result);
} }
...@@ -40,6 +43,7 @@ impl ProductService { ...@@ -40,6 +43,7 @@ impl ProductService {
} }
let product: Product = product_opt.unwrap(); let product: Product = product_opt.unwrap();
NotificationService.notify(&product.product_type, "DELETED", product.clone());
return Ok(Json::from(product)); return Ok(Json::from(product));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment