Пример #1
0
 def updateCompany(self, compid, form):
     dao = CompanyDAO()
     if not dao.getCompanyById(compid):
         return jsonify(Error="Company not found."), 404
     else:
         if len(form) != 1:
             return jsonify(Error="Malformed update request"), 400
         else:
             compname = form['compname']
             if compname:
                 dao.update(compid, compname)
                 result = self.build_company_attributes(compid, compname)
                 return jsonify(Company=result), 200
             else:
                 return jsonify(
                     Error="Unexpected attributes in update request"), 400
Пример #2
0
    def updateCompany(self, company_id, json):
        dao = CompanyDAO()
        if not dao.getCompanyById(company_id):
            return jsonify(Error="Company not found."), 404
        else:
            company_id = json['company_id']
            company_name = json['company_name']
            company_address = json['company_address']
            company_phone = json['company_phone']

            if company_id and company_name and company_address and company_phone:
                dao.update(company_id, company_name, company_address,
                           company_phone)
                result = self.build_company_attributes(company_id,
                                                       company_name,
                                                       company_address,
                                                       company_phone)
                return jsonify(Company=result), 200
            else:
                return jsonify(
                    Error="Unexpected attributes in update request"), 400