def product_insert(): data = request.json c1 = bo.Product(data['ProductID'], data['ProductName'], data['SupplierID'], data['CategoryID'], data['Unit'], data['Price']) c2 = do.Product(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def update_product_by_id(product_id): data = request.json c = bo.Product(ProductID=product_id, ProductName=data['ProductName'], SupplierID=data['SupplierID'], CategoryID=data['CategoryID'], Unit=data['Unit'], Price=data['Price']) result = do.Product(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def delete_product_by_id(product_id): c = bo.Product(ProductID=product_id) result = do.Product(ConnectionData).delete(c) return jsonify({'message': result[0]}), result[1]
def get_product_by_id(product_id): c = bo.Product(ProductID=product_id) result = do.Product(ConnectionData).get_by_id(c) if result[1] != 200: return jsonify({'message': result[0]}), result[1] return jsonify(result[0].to_json()), 200
def get_all_product(): result = do.Product(ConnectionData).get_all() return jsonify(result), 200