Beispiel #1
0
def get_drinker(name):
    try:
        if name is None:
            raise ValueError("Drinker is not specified.")
        return jsonify(database.get_drinker_info(name))
    except ValueError as e:
        return make_response(str(e), 400)
    except Exception as e:
        return make_response(str(e), 500)
Beispiel #2
0
def update_drinker(name, column, value):
    try:
        drinker = database.get_drinker_info(name)
        if drinker is None:
            return make_response("No drinker found")
        return jsonify(database.update_drinker(name, column, value))
    except ValueError as e:
        return make_response(str(e), 400)
    except Exception as e:
        return make_response(str(e), 500) 
def get_drinker(FirstName, LastName):
    try:
        if FirstName is None and LastName is None:
            raise ValueError(
                "First name and last name of drinker are not fully specified.")
        return jsonify(database.get_drinker_info(FirstName, LastName))
    except ValueError as e:
        return make_response(str(e), 400)
    except Exception as e:
        return make_response(str(e), 500)
Beispiel #4
0
def get_spending_by_bar(name):
    try:
        if name is None:
            raise ValueError('Drinker is not specified.')
        drinker = database.get_drinker_info(name)
        if drinker is None:
            return make_response("No Drinker found with the given name.", 404)
        return jsonify(database.spending_by_bar(name))
    except ValueError as e:
        return make_response(str(e), 400)
    except Exception as e:
        return make_response(str(e), 500)