コード例 #1
0
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]
コード例 #2
0
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
コード例 #3
0
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]
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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]
コード例 #7
0
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]
コード例 #8
0
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]
コード例 #9
0
ファイル: app.py プロジェクト: tuan19989/CNW
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]
コード例 #10
0
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
コード例 #11
0
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
コード例 #12
0
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]
コード例 #13
0
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
コード例 #14
0
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
コード例 #15
0
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]
コード例 #16
0
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
コード例 #17
0
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
コード例 #18
0
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
コード例 #19
0
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
コード例 #20
0
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]