def get_all_Products(): c = Products(connection_data) result = c.get_all_Products() return jsonify({'data': result})
def get_one_product(id): products = ProductsEntity(ProductID=id) c = Products(connection_data) result = c.get_one_Products(products) return jsonify({'data': result})
def add_products(): data = request.json products = ProductsEntity(product_name =data['product_name'], supplier_id=data['supplier_id'], category_id=data['category_id'], unit=data['unit'], price=data['price']) c = Products(connection_data) message = c.insert(products) if message is None: return jsonify({ 'message': 'Cannot insert data' }), 500 return jsonify({ 'message': message })
def add_Products(): data = request.json pro = ProductsEntity(ProductName=data['ProductName'], SupplierID=data['SupplierID'], CategoryID=data['CategoryID'], Unit=data['Unit'], Price=data['Price']) c = Products(connection_data) message = c.insert_Products(pro) if message is None: return jsonify({'message': 'Cannot insert data'}), 500 return jsonify({'message': message})
def delete_Products_by_id(id): if request.method == 'DELETE': # Delete user by id product = ProductsEntity(ProductID=id) c = Products(connection_data) result = c.delete_Products(product) return jsonify({'message': result[0]}), result[1] else: # Update user by id data = request.json product = ProductsEntity(ProductID=id, ProductName=data['ProductName'], SupplierID=data['SupplierID'], CategoryID=data['CategoryID'], Unit=data['Unit'], Price=data['Price']) c = Products(connection_data) result = c.update_Products(product) return jsonify({'message': result[0]}), result[1]
def delete_products_by_id(id): if request.method == 'DELETE': # Delete user by id products = ProductsEntity(product_id=id) c = Products(connection_data) result = c.delete(products) return jsonify({ 'message': result[0] }), result[1] else: data = request.json products = ProductsEntity(product_id=id, product_name =data['product_name'], supplier_id=data['supplier_id'], category_id=data['category_id'], unit=data['unit'], price=data['price']) c = Products(connection_data) result = c.update(products) return jsonify({ 'message': result[0] }), result[1]