def update_category_by_id(category_id): data = request.json category = bo.Category(CategoryID=category_id, CategoryName=data['CategoryName'], Description=data['Description']) result = do.Category(ConnectionData).update(category) return jsonify({'message': result[0]}), result[1]
def insert_order_detail(): data = request.json orderr = bo.OrderDetail(OrderID=data['OrderID'], ProductID=data['ProductID'], Quantity=data['Quantity']) result = do.OrderDetail(ConnectionData).insert(orderr) return jsonify({'message': result}), 200
def update_order_detail_by_id(odd_id): data = request.json orderr = bo.OrderDetail(OrderDetailID=odd_id, OrderID=data['OrderID'], ProductID=data['ProductID'], Quantity=data['Quantity']) result = do.OrderDetail(ConnectionData).update(orderr) return jsonify({'message': result[0]}), result[1]
def insert_order(): data = request.json order = bo.Order(CustomerID=data['CustomerID'], EmployeeID=data['EmployeeID'], OrderDate=data['OrderDate'], ShipperID=data['ShipperID']) result = do.Order(ConnectionData).insert(order) return jsonify({'message': result}), 200
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_order_by_id(od_id): data = request.json order = bo.Order(OrderID=od_id, CustomerID=data['CustomerID'], EmployeeID=data['EmployeeID'], OrderDate=data['OrderDate'], ShipperID=data['ShipperID']) result = do.Order(ConnectionData).update(order) return jsonify({'message': result[0]}), result[1]
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 update_supplier_by_id(supplier_id): data = request.json c = bo.Supplier(SupplierID=supplier_id, SupplierName=data['SupplierName'], ContactName=data['ContactName'], Address=data['Address'], City=data['City'], PostalCode=data['PostalCode'], Country=data['Country'], Phone=data['Phone']) result = do.Supplier(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1]
def handle_employee(employee_id): if request.method == 'GET': c = bo.Employee(EmployeeID=employee_id) result = do.Employee(ConnectionData).get_by_id(c) if result[1] != 200: return jsonify({'message': result[0]}), result[1] return jsonify(result[0].to_json()), 200 elif request.method == 'PUT': data = request.json c = bo.Employee(EmployeeID=employee_id, LastName=data['LastName'], FirstName=data['FirstName'], Birthdate=data['Birthdate'], Photo=data['Photo'], Notes=data['Notes']) result = do.Employee(ConnectionData).update(c) return jsonify({'message': result[0]}), result[1] elif request.method == 'DELETE': c = bo.Employee(EmployeeID=employee_id) result = do.Employee(ConnectionData).delete(c) return jsonify({'message': result[0]}), result[1]
def employee_insert(): data = request.json c1 = bo.Employee(LastName=data['LastName'], FirstName=data['FirstName'], Birthdate=data['Birthdate'], Photo=data['Photo'], Notes=data['Notes']) c2 = do.Employee(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
def supplier_insert(): data = request.json c1 = bo.Supplier(SupplierName=data['SupplierName'], ContactName=data['ContactName'], Address=data['Address'], City=data['City'], PostalCode=data['PostalCode'], Country=data['Country'], Phone=data['Phone']) c2 = do.Supplier(ConnectionData) s1 = c2.insert(c1) result = {} result['message'] = s1 return jsonify(result), 200
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 insert_category(): data = request.json category = bo.Category(CategoryName=data['CategoryName'], Description=data['Description']) result = do.Category(ConnectionData).insert(category) return jsonify({'message': result}), 200
def delete_order_detail_by_id(odd_id): c = bo.OrderDetail(OrderDetailID=odd_id) result = do.OrderDetail(ConnectionData).delete(c) return jsonify({'message': result[0]}), result[1]
def get_category_by_id(category_id): category = bo.Category(CategoryID=category_id) result = do.Category(ConnectionData).get_by_id(category) if result[1] != 200: return jsonify({'message': result[0]}), result[1] return jsonify(result[0].to_json()), 200
def test_insertCustomer(): c2 = do.Customer(ConnectionData) c1 = bo.Customer(1, 'Phạm Trung Hoài', '0369559606', '588 Núi Thành', 'Đà Nẵng', '550000', 'Việt Nam') s1 = c2.insert(c1) return s1
def get_order_detail_by_id(odd_id): orderr = bo.OrderDetail(OrderDetailID=odd_id) result = do.OrderDetail(ConnectionData).get_by_id(orderr) if result[1] != 200: return jsonify({'message': result[0]}), result[1] return jsonify(result[0].to_json()), 200
def test_insertEmployee(): c2 = do.Employee(ConnectionData) c1 = bo.Employee(1, 'Truong', 'Hieu', '1999-07-12', 'truonghieu.jpg', 'VietNam') s1 = c2.insert(c1) return s1
def delete_category_by_id(category_id): c = bo.Category(CategoryID=category_id) result = do.Category(ConnectionData).delete(c) return jsonify({'message': result[0]}), result[1]