def updateSupplierJson(self, supplierid, json): dao = SuppliersDAO() if not dao.getSupplierById(supplierid): return jsonify(Error="Admin not found."), 404 else: username = json['UserName'] password = json['Password'] email = json['Email'] slocation = json['SLocation'] affiliation = json['affiliation'] firstname = json['FirstName'] lastname = json['LastName'] dateofbirth = json['DateofBirth'] gender = json['Gender'] categoryid = json['CategoryID'] categoryname = json['CategoryName'] if username and password and email and slocation and affiliation and firstname and lastname and dateofbirth and gender and categoryid and categoryname: dao.update(supplierid, username, password, email, slocation, affiliation, firstname, lastname, dateofbirth, gender, categoryid, categoryname) result = self.build_suppliers_attributes( supplierid, username, password, email, slocation, affiliation, firstname, lastname, dateofbirth, gender, categoryid, categoryname) return jsonify(Administrators=result), 200
def updateSupplier(self, supplierid, form): dao = SuppliersDAO() if not dao.getSupplierById(supplierid): return jsonify(Error="Supplier not found."), 404 else: if len(form) != 11: return jsonify(Error="Malformed update request"), 400 else: username = form['UserName'] password = form['Password'] email = form['Email'] slocation = form['SLocation'] affiliation = form['affiliation'] firstname = form['FirstName'] lastname = form['LastName'] dateofbirth = form['DateofBirth'] gender = form['Gender'] categoryid = form['CategoryID'] categoryname = form['CategoryName'] if username and password and email and slocation and affiliation and firstname and lastname and dateofbirth and gender and categoryid and categoryname: dao.update(username, password, email, slocation, affiliation, firstname, lastname, dateofbirth, gender, categoryid, categoryname) result = self.build_suppliers_attributes( username, password, email, slocation, affiliation, firstname, lastname, dateofbirth, gender, categoryid, categoryname) return jsonify(Suppliers=result), 200 else: return jsonify( Error="Unexpected attributes in update request"), 400