Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit bd96542d authored by vissutagunawan's avatar vissutagunawan
Browse files

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

parent 665ee1a9
No related branches found
No related tags found
No related merge requests found
......@@ -5,8 +5,6 @@ use crate::model::subscriber::Subscriber;
use crate::service::notification::NotificationService;
use bambangshop::Result;
use super::product;
#[post("/subscribe/<product_type>", data = "<subscriber>")]
pub fn subscribe(
product_type: &str,
......
......@@ -14,6 +14,12 @@ 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);
}
......@@ -42,6 +48,8 @@ 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.
Finish editing this message first!
Please register or to comment