def delete_assurance(assurance_id):
    try:
        response.status = 200
        result = commons_assurance_service.delete_by_id(assurance_id)
    except TypeError:
        return commons_utilitaire.error_handler(400, invalid_parameters, response)
    if not result:
        return commons_utilitaire.error_handler(404, "identifiant not find", response)
def update_assurance():
    try:
        response.status = 200
        assurance = commons_utilitaire.get_record_from_body(request, Assurance)
        result = commons_assurance_service.update(assurance)
    except TypeError:
        return commons_utilitaire.error_handler(400, invalid_parameters, response)
    if not result:
        return commons_utilitaire.error_handler(404, "identifiant not find", response)
def delete_assurance(assurance_id):
    try:
        response.status = 200
        result = commons_assurance_service.delete_by_id(assurance_id)
    except TypeError:
        return commons_utilitaire.error_handler(400, invalid_parameters,
                                                response)
    if not result:
        return commons_utilitaire.error_handler(404, "identifiant not find",
                                                response)
def update_assurance():
    try:
        response.status = 200
        assurance = commons_utilitaire.get_record_from_body(request, Assurance)
        result = commons_assurance_service.update(assurance)
    except TypeError:
        return commons_utilitaire.error_handler(400, invalid_parameters,
                                                response)
    if not result:
        return commons_utilitaire.error_handler(404, "identifiant not find",
                                                response)
def create_assurance():
    try:
        assurance = commons_utilitaire.get_record_from_body(request, Assurance)
        response.status = 201
        return dumps(commons_assurance_service.create(assurance), default=commons_utilitaire.jdefault)
    except TypeError:
        return commons_utilitaire.error_handler(400, invalid_parameters, response)
Beispiel #6
0
def delete_car(car_id):
    try:
        response.status = 200
        result = car_service.delete_by_id(car_id)
        return commons_utilitaire.json_bool_response(result)
    except TypeError as e:
        print(e)
        return commons_utilitaire.error_handler(400, invalid_parameters, response)
Beispiel #7
0
def get_by_id(car_id):
    try:
        response.status = 200
        car = car_service.find_by_id(car_id)
        return commons_utilitaire.json_response(car, entity_not_found)
    except TypeError as e:
        print(e)
        return commons_utilitaire.error_handler(400, invalid_parameters, response)
Beispiel #8
0
def get_all():
    try:
        response.status = 200
        cars = car_service.find_all()
        list = [car.to_dict() for car in cars]
        return dumps(list)
    except TypeError:
        return commons_utilitaire.error_handler(400, invalid_parameters, response)
Beispiel #9
0
def update_car():
    try:
        response.status = 200
        car = commons_utilitaire.get_record_from_body(request, Car)
        result = car_service.update(car)
        return commons_utilitaire.json_bool_response(result)
    except TypeError as e:
        print(e)
        return commons_utilitaire.error_handler(400, invalid_parameters, response)
def create_assurance():
    try:
        assurance = commons_utilitaire.get_record_from_body(request, Assurance)
        response.status = 201
        return dumps(commons_assurance_service.create(assurance),
                     default=commons_utilitaire.jdefault)
    except TypeError:
        return commons_utilitaire.error_handler(400, invalid_parameters,
                                                response)
def create_driver():
    try:
        response.status = 200
        driver = commons_utilitaire.get_record_from_body(request, Driver)
        result = driver_service.create(driver)
        return commons_utilitaire.json_bool_response(result)
    except TypeError as e:
        print(e)
        return commons_utilitaire.error_handler(400, invalid_parameters,
                                                response)
Beispiel #12
0
def error500(error):
    table = "../../cars"
    body = commons_utilitaire.error_handler(400, invalid_parameters, response)
    footer = template('footer.tpl', table=table)
    return {"body": body, "footer": footer}
Beispiel #13
0
def error500(error):
    table = "../../drivers"
    body = commons_utilitaire.error_handler(400, invalid_parameters, response)
    footer = template('footer.tpl', table=table)
    return {"body": body, "footer": footer}