def getResourceIDByPartsID(self, Partsid): dao = PartsDAO() row = dao.getResourceIDByPartsID(Partsid) if not row: return jsonify(Error="Parts Not Found "), 404 else: Parts = self.build_parts_dict(row) return jsonify(Parts=Parts)
def updateResourceJson(self, Partsid, json): dao = PartsDAO() if not dao.getPartsById(Partsid): return jsonify(Error="Parts not found."), 404 else: Partsmaterial = json['PartsMaterial'] Partscolor = json['PartsColor'] Partsdescription = json['PartsDescription'] if Partsmaterial and Partscolor and Partsdescription: dao.update(Partsid, Partsmaterial, Partscolor, Partsdescription) resourceid = dao.getResourceIDByPartsID(Partsid) result = self.build_parts_attributes(Partsid, Partsmaterial, Partscolor, Partsdescription, resourceid) return jsonify(Parts=result), 400 else: return jsonify( Error="Unexpected attributes in update request"), 400