Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit dabf68f4 authored by Scallss's avatar Scallss
Browse files

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

parent bf470ec3
No related branches found
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,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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment