def get_all_Suppliers(): c = Suppliers(connection_data) result = c.get_all_Suppliers() return jsonify({'data': result})
def get_one_supplier(id): supplier = SuppliersEntity(SupplierID=id) c = Suppliers(connection_data) result = c.get_one_Suppliers(supplier) return jsonify({'data': result})
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 })
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})
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]
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]