def deleteResource(self, rid):
     dao = ResourcesDAO()
     if not dao.getResourceById(rid):
         return jsonify(Error="Resource not found."), 404
     else:
         dao.delete(rid)
         return jsonify(DeleteStatus="OK"), 200
 def getSuppliersByResourceId(self, rid):
     dao = ResourcesDAO()
     if not dao.getResourceById(rid):
         return jsonify(Error="Resource Not Found"), 404
     suppliers_list = dao.getSuppliersByResourceId(rid)
     result_list = []
     for row in suppliers_list:
         result = self.build_supplier_dict(row)
         result_list.append(result)
     return jsonify(Suppliers=result_list)
 def updateResource(self, rid, form):
     dao = ResourcesDAO()
     if not dao.getResourceById(rid):
         return jsonify(Error="Resource not found."), 404
     else:
         if len(form) != 4:
             return jsonify(Error="Malformed update request"), 400
         else:
             sid = form['sid']
             resv_amount = form['resv_amount']
             cost = form['cost']
             rname = form['rname']
             if rname and resv_amount and cost and sid:
                 dao.update(rid, sid, rname, cost, resv_amount)
                 result = self.build_resource_attributes(
                     rid, sid, rname, cost, resv_amount)
                 return jsonify(Resource=result), 200
             else:
                 return jsonify(
                     Error="Unexpected attributes in update request"), 400