diff options
Diffstat (limited to 'dichroism/src/dtos/product_patch.rs')
-rw-r--r-- | dichroism/src/dtos/product_patch.rs | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/dichroism/src/dtos/product_patch.rs b/dichroism/src/dtos/product_patch.rs deleted file mode 100644 index f231469..0000000 --- a/dichroism/src/dtos/product_patch.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::models::Product; - -#[derive(Debug, Deserialize)] -pub struct ProductPatch { - pub id: i32, - pub name: Option<String>, - pub quantity: Option<i32>, - pub cents: Option<i32>, - pub description: Option<String>, - pub featured: Option<bool>, - pub category_path: Option<String>, - pub photo_set: Option<i32>, -} - -impl ProductPatch { - pub fn patch(self, product: &mut Product) { - if let Some(name) = self.name { - product.name = name; - } - if let Some(category) = self.category_path { - product.category = category; - } - if let Some(description) = self.description { - product.description = description; - } - - product.quantity = self.quantity.unwrap_or(product.quantity); - product.cents = self.cents.unwrap_or(product.cents); - product.featured = self.featured.unwrap_or(product.featured); - } -} |