Beispiel #1
0
    def getCompanyByName(self, name):
        dao = CompanyDAO()
        cms = []
        items = dao.getCompanyByName(name)

        for i in items:
            result = self.build_company_dict(i)
            cms.append(result)

        return jsonify(Companies=cms)
Beispiel #2
0
 def searchCompany(self, args):
     company_name = args.get('company_name')
     company_address = args.get('company_address')
     company_phone = args.get('company_phone')
     dao = CompanyDAO()
     companies_list = []
     if (len(args) == 1) and company_name:
         companies_list = dao.getCompanyByName(company_name)
     elif (len(args) == 1) and company_address:
         companies_list = dao.getCompanyByAddress(company_address)
     elif (len(args) == 1) and company_phone:
         companies_list = dao.getCompanyByPhone(company_phone)
     else:
         return jsonify(Error="Malformed query string"), 400
     result_list = []
     for row in companies_list:
         result = self.build_company_dict(row)
         result_list.append(result)
     return jsonify(Company=result_list)