コード例 #1
0
def get_all_Suppliers():

    c = Suppliers(connection_data)

    result = c.get_all_Suppliers()

    return jsonify({'data': result})
コード例 #2
0
def get_one_supplier(id):
    supplier = SuppliersEntity(SupplierID=id)

    c = Suppliers(connection_data)

    result = c.get_one_Suppliers(supplier)

    return jsonify({'data': result})
コード例 #3
0
ファイル: app.py プロジェクト: tunghqh/KTWEB
def add_suppliers():
    data = request.json
    suppliers = SuppliersEntity(supplier_name=data['supplier_name'],
                                contact_name=data['contact_name'],
                                address=data['address'],
                                city=data['city'],
                                postal_code=data['postal_code'],
                                country=data['country'],
                                phone=data['phone'])
    c = Suppliers(connection_data)
    message = c.insert(suppliers)
    if message is None:
        return jsonify({
            'message': 'Cannot insert data'
        }), 500
    return jsonify({
        'message': message
    })
コード例 #4
0
def add_Suppliers():

    data = request.json

    supp = SuppliersEntity(SupplierName=data['SupplierName'],
                           ContactName=data['ContactName'],
                           Address=data['Address'],
                           City=data['City'],
                           PostalCode=data['PostalCode'],
                           Country=data['Country'],
                           Phone=data['Phone'])

    c = Suppliers(connection_data)

    message = c.insert_Suppliers(supp)

    if message is None:

        return jsonify({'message': 'Cannot insert data'}), 500

    return jsonify({'message': message})
コード例 #5
0
def delete_Suppliers_by_id(id):

    if request.method == 'DELETE':

        # Delete user by id

        suppli = SuppliersEntity(SupplierID=id)

        c = Suppliers(connection_data)

        result = c.delete_Suppliers(suppli)

        return jsonify({'message': result[0]}), result[1]

    else:
        # Update user by id

        data = request.json

        suppli = SuppliersEntity(SupplierID=id,
                                 SupplierName=data['SupplierName'],
                                 ContactName=data['ContactName'],
                                 Address=data['Address'],
                                 City=data['City'],
                                 PostalCode=data['PostalCode'],
                                 Country=data['Country'],
                                 Phone=data['Phone'])

        c = Suppliers(connection_data)

        result = c.update_Suppliers(suppli)

        return jsonify({'message': result[0]}), result[1]
コード例 #6
0
ファイル: app.py プロジェクト: tunghqh/KTWEB
def delete_suppliers_by_id(id):
    if request.method == 'DELETE':
        # Delete user by id
        suppliers = SuppliersEntity(supplier_id =id)
        c = Suppliers(connection_data)
        result = c.delete(suppliers)
        return jsonify({
            'message': result[0]
        }), result[1]
    else:
        # Update user by id
        data = request.json
        suppliers = SuppliersEntity(supplier_id =id,
                                   supplier_name=data['supplier_name'],
                                contact_name=data['contact_name'],
                                address=data['address'],
                                city=data['city'],
                                postal_code=data['postal_code'],
                                country=data['country'],
                                phone=data['phone'])
        c = Suppliers(connection_data)
        result = c.update(suppliers)
        return jsonify({
            'message': result[0]
        }), result[1]