def deleteParts(self, Partsid): dao = PartsDAO() if not dao.getPartsById(Partsid): return jsonify(Error="Resource not found."), 404 else: dao.delete(Partsid) return jsonify(DeleteStatus="OK"), 200
def getPartsByID(self, Partsid): dao = PartsDAO() row = dao.getPartsById(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