From 7d3aaf0c4e235c2aca8a1ca68f12d4393d16b277 Mon Sep 17 00:00:00 2001 From: unknown <fc00617@surrey.ac.uk> Date: Tue, 7 May 2024 14:26:38 +0100 Subject: [PATCH] Updated CheckOutController and DeleteFromItemController --- .../app/controllers/CheckOutController.py | 5 ++--- .../app/controllers/DeleteFromItemController.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Orders_Microservice_Group3/app/controllers/CheckOutController.py b/Orders_Microservice_Group3/app/controllers/CheckOutController.py index 1f2d33b1..a1a2f5d5 100644 --- a/Orders_Microservice_Group3/app/controllers/CheckOutController.py +++ b/Orders_Microservice_Group3/app/controllers/CheckOutController.py @@ -22,10 +22,9 @@ def handle_checkout(): # Check for errors in the result and return appropriate responses if 'error' in checkout_result: - return jsonify({"error": checkout_result["error"]}), 500 # or another appropriate status code - + return jsonify({"error": checkout_result["error"]}), 500 # If checkout is successful, publish an event to Kafka for each item purchased - for item in checkout_result.get('item_details', []): # Ensure that item_details are included in checkout_result + for item in checkout_result.get('item_details', []): event_data = { "ProductID": item['ProductID'], "QuantityPurchased": item['Quantity'] diff --git a/Orders_Microservice_Group3/app/controllers/DeleteFromItemController.py b/Orders_Microservice_Group3/app/controllers/DeleteFromItemController.py index 5520377b..ca51e9c3 100644 --- a/Orders_Microservice_Group3/app/controllers/DeleteFromItemController.py +++ b/Orders_Microservice_Group3/app/controllers/DeleteFromItemController.py @@ -17,5 +17,5 @@ def delete_item(cart_item_id): result = delete_item_from_cart(user_id, cart_item_id) if "error" in result: - return jsonify(result), 404 # Or another appropriate status code based on the error + return jsonify(result), 404 return jsonify(result), 200 \ No newline at end of file -- GitLab