def get_all_OrderDetails(): c = OrderDetails(connection_data) result = c.get_all_OrderDetails() return jsonify({'data': result})
def get_one_orderDetail(id): orderDetail = OrderDetailsEntity(OrderDetailID=id) c = OrderDetails(connection_data) result = c.get_one_OrderDetails(orderDetail) return jsonify({'data': result})
def add_orderdetails(): data = request.json orderdetails = OrderDetailsEntity(order_id =data['order_id'], product_id=data['product_id'], quantity=data['quantity']) c = OrderDetails(connection_data) message = c.insert(orderdetails) if message is None: return jsonify({ 'message': 'Cannot insert data' }), 500 return jsonify({ 'message': message })
def add_OrderDetails(): data = request.json ord = OrderDetailsEntity(OrderID=data['OrderID'], ProductID=data['ProductID'], Quantity=data['Quantity']) c = OrderDetails(connection_data) message = c.insert_OrderDetails(ord) if message is None: return jsonify({'message': 'Cannot insert data'}), 500 return jsonify({'message': message})
def delete_orderDetail_by_id(id): if request.method == 'DELETE': # Delete user by id ord = OrderDetailsEntity(OrderDetailID=id) c = OrderDetails(connection_data) result = c.delete_OrderDetails(ord) return jsonify({'message': result[0]}), result[1] else: # Update user by id data = request.json ord = OrderDetailsEntity(OrderDetailID=id, OrderID=data['OrderID'], ProductID=data['ProductID'], Quantity=data['Quantity']) c = OrderDetails(connection_data) result = c.update_OrderDetails(ord) return jsonify({'message': result[0]}), result[1]
def delete_orderDetails_by_id(id): if request.method == 'DELETE': # Delete user by id orderdetails = OrderDetailsEntity(orderdetail_id=id) c = OrderDetails(connection_data) result = c.delete(orderdetails) return jsonify({ 'message': result[0] }), result[1] else: # Update user by id data = request.json orderdetails = OrderDetailsEntity(orderdetail_id=id, order_id =data['order_id'], product_id=data['product_id'], quantity=data['quantity'] ) c = OrderDetails(connection_data) result = c.update(orderdetails) return jsonify({ 'message': result[0] }), result[1]