Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit f51d9fe9 authored by noQils's avatar noQils
Browse files

Edit Product service methods to call notify after create/delete.

parent b77ed966
Branches
No related tags found
No related merge requests found
......@@ -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));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment