def user_insert(): data = request.json c1 = bo.Customer(1, data['CustomerName'], data['ContactName'], data['Address'], data['City'], data['PostalCode'], data['Country']) c2 = do.Customer(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def update_user_by_id(customer_id): data = request.json c = bo.Customer(CustomerID=customer_id, CustomerName=data['CustomerName'], ContactName=data['ContactName'], Address=data['Address'], City=data['City'], PostalCode=data['PostalCode'], Country=data['Country']) result = do.Customer(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def delete_user_by_id(customer_id): c = bo.Customer(CustomerID=customer_id) result = do.Customer(ConnectionData).delete(c) return jsonify({'message': result[0]}), result[1]
def get_user_by_id(customer_id): c = bo.Customer(CustomerID=customer_id) result = do.Customer(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_user(): result = do.Customer(ConnectionData).get_all() return jsonify(result), 200
def test_insert(): c2 = do.Customer(ConnectionData) c1 = bo.Customer('Tien', 'Do', '1999', 'QuangBinh', 'DongHoi', 'VietNam') s1 = c2.insert(c1) return s1