sdacelo commited on
Commit
be370fd
·
1 Parent(s): d4a5011

uncomment delete

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -109,16 +109,16 @@ def update_product(product_id: str, updated_product: Product):
109
  return {"message": "Product successfully updated !"}
110
  raise HTTPException(status_code=404, detail="Product not found")
111
 
112
- # DELETE
113
- # @app.delete("/customers/{customer_id}", summary="Delete a customer", description="Allows you to delete a customer by their ID.", tags=["Customers"])
114
- # def delete_customer(customer_id: str):
115
- # initial_length = len(efd.customers)
116
- # efd.customers = [c for c in efd.customers if c["customer_id"] != customer_id]
117
- # if len(efd.customers) < initial_length:
118
- # return {"message": "Customer successfully deleted !"}
119
- # raise HTTPException(status_code=404, detail="Customer not found")
120
-
121
- # @app.delete("/products/{product_id}", summary="Delete a product", description="Allows you to delete a product by its ID.", tags=["Products"])
122
- # def delete_product(product_id: str):
123
- # efd.products = [p for p in efd.products if p["product_id"] != product_id]
124
- # return {"message": "Product successfully deleted !"}
 
109
  return {"message": "Product successfully updated !"}
110
  raise HTTPException(status_code=404, detail="Product not found")
111
 
112
+ DELETE
113
+ @app.delete("/customers/{customer_id}", summary="Delete a customer", description="Allows you to delete a customer by their ID.", tags=["Customers"])
114
+ def delete_customer(customer_id: str):
115
+ initial_length = len(efd.customers)
116
+ efd.customers = [c for c in efd.customers if c["customer_id"] != customer_id]
117
+ if len(efd.customers) < initial_length:
118
+ return {"message": "Customer successfully deleted !"}
119
+ raise HTTPException(status_code=404, detail="Customer not found")
120
+
121
+ @app.delete("/products/{product_id}", summary="Delete a product", description="Allows you to delete a product by its ID.", tags=["Products"])
122
+ def delete_product(product_id: str):
123
+ efd.products = [p for p in efd.products if p["product_id"] != product_id]
124
+ return {"message": "Product successfully deleted !"}