def update(id):
    foundJob = jobDAO.findByID(id)
    if not foundJob:
        abort(404)

    if not request.json:
        abort(400)
    reqJson = request.json

    if 'salary' in reqJson and type(reqJson['salary']) is not int:
        abort(400)

    if 'location' in reqJson:
        foundJob['location'] = reqJson['location']

    if 'jobTitle' in reqJson:
        foundJob['jobTitle'] = reqJson['jobTitle']

    if 'company' in reqJson:
        foundJob['company'] = reqJson['company']

    if 'salary' in reqJson:
        foundJob['salary'] = reqJson['salary']

    values = (
        foundJob['location'],
        foundJob['jobTitle'],
        foundJob['company'],
        foundJob['salary'],
        foundJob['id'],
    )
    jobDAO.update(values)
    return jsonify(foundJob)
Exemplo n.º 2
0
def update(id):

    foundjob = jobDAO.findByID(id)
    if not foundjob:
        abort(404)

    if not request.json:
        abort(400)
    reqJson = request.json
    if 'Salary' in reqJson and type(reqJson['Salary']) is not int:
        abort(400)

    if 'JobType' in reqJson:
        foundjob['JobType'] = reqJson['JobType']
    if 'Company' in reqJson:
        foundjob['Company'] = reqJson['Company']
    if 'Salary' in reqJson:
        foundjob['Salary'] = reqJson['Salary']

    if 'Location' in reqJson:
        foundjob['Location'] = reqJson['Location']

    values = (foundjob['JobType'], foundjob['Company'], foundjob['Salary'],
              foundjob['Location'], foundjob['id'])
    jobDAO.update(values)
    return jsonify(foundjob)
def findById(id):
    foundJob = jobDAO.findByID(id)

    return jsonify(foundJob)