def insertFuel(self, json): supplier_id = json["supplier_id"] category_id = json["category_id"] fuel_name = json["fuel_name"] fuel_brand = json["fuel_brand"] fuel_quantity = json["fuel_quantity"] fuel_price = json["fuel_price"] fuel_type = json["fuel_type"] fuel_gallons = json["fuel_gallons"] if supplier_id and category_id and fuel_name and fuel_brand and ( fuel_quantity >= 0) and (fuel_price >= 0) and fuel_type and fuel_gallons: resource_dao = ResourceDAO() resource_id = resource_dao.insert(supplier_id, category_id, fuel_name, fuel_brand, fuel_quantity, fuel_price) fuel_dao = FuelDAO() fuel_id = fuel_dao.insert(resource_id, fuel_type, fuel_gallons) result = self.build_fuel_attributes(fuel_id, resource_id, supplier_id, category_id, fuel_name, fuel_brand, fuel_quantity, fuel_price, fuel_type, fuel_gallons) return jsonify(Fuel=result), 201 else: return jsonify(Error="Unexpected attributes in post request"), 400
def insertFuel(self, form): print("form: ", form) if len(form) != 4: return jsonify(Error="Malformed post request") Fueltype = form['FuelType'] Fueloctenage = form['FuelOctenage'] Fueldescription = form['Fueldescription'] resourceid = form['resourceid'] if Fueltype and Fueloctenage and Fueldescription and resourceid: dao = FuelDAO() Fuelid = dao.insert( Fueltype, Fueloctenage, Fueldescription, resourceid, ) result = self.build_fuel_attributes( Fuelid, Fueltype, Fueloctenage, Fueldescription, resourceid, ) return jsonify(Fuel=result), 201 else: return jsonify(Error="Unexpected attributes in post request")
def insertFuelJson(self, json): ftype = json['ftype'] fsupplier = json['fsupplier'] fquantity = json['fquantity'] flocation = json['flocation'] if ftype and fsupplier and fquantity and flocation: dao = FuelDAO() result = dao.insert(ftype, fsupplier, fquantity, flocation) return jsonify(Fuel=result), 201 else: return jsonify(Error="Unexpected attributes in post request"), 400
def insertFuelJson(self, json): Fueltype = json['FuelType'] Fueloctenage = json['FuelOctenage'] Fueldescription = json['FuelDescription'] resourceid = json['ResourceID'] if Fueltype and Fueloctenage and Fueldescription and resourceid: dao = FuelDAO() Fuelid = dao.insert(Fueltype, Fueloctenage, Fueldescription, resourceid) result = self.build_fuel_attributes(Fuelid, Fueltype, Fueloctenage, Fueldescription, resourceid) return jsonify(Fuel=result), 201 else: return jsonify(Error="Unexpected attributes in post request")
def insert(self, item, supplier_id): fuel_type = item['fuel_type'] resource_name = item['resource_name'] resource_price = item['resource_price'] resource_city = item['resource_city'] resource_quantity = item['resource_quantity'] resource_description = item['resource_description'] resource_date = item['resource_date'] if fuel_type and resource_name and resource_price and resource_city and resource_quantity and resource_description and resource_date: dao = FuelDAO() rid = dao.insert(fuel_type, resource_name, resource_price, resource_city, resource_quantity, resource_description, resource_date, supplier_id) return jsonify(Fuel=self.build_fuel_attrs( fuel_type, resource_name, resource_price, resource_city, resource_quantity, resource_description, resource_date)) else: return jsonify(Error="Unexpected attributes in POST request"), 400