Ejemplo n.º 1
0
async def get_Hotel(name: str):
    hotel_in_db = get_hotel(name)
    if hotel_in_db == None:
        raise HTTPException(status_code=404,
                            detail="EL REGISTRO NO EXISTE EN LA BASE DE DATOS")
    hotel_out = HotelOut(**hotel_in_db.dict())
    return hotel_out
Ejemplo n.º 2
0
async def update_this_hotel(updateHotel: HotelOut):
    hotel_in_db = get_hotel(updateHotel.nombre)
    if hotel_in_db == None:
        raise HTTPException(
            status_code=404,
            detail=
            "EL REGISTRO NO EXISTE EN LA BASE DE DATOS NO SE PUEDE ACTUALIZAR")
    update_hotel(updateHotel)
    return {"EL REGISTRO SE ACTUALIZO DE MANERA CORRECTA"}
Ejemplo n.º 3
0
async def delete_this_hotel(nombre: str):
    hotel_in_db = get_hotel(nombre)
    if hotel_in_db == None:
        raise HTTPException(
            status_code=404,
            detail=
            "EL REGISTRO NO SE PUEDE BORRAR NO EXISTE EN LA BASE DE DATOS")
    delete_hotel(nombre)
    return {"EL REGISTRO SE BORRRO DE LA BASE DE DATOS"}
Ejemplo n.º 4
0
async def get_balance(nombre: str):

    hotel_in_db = get_hotel(nombre)

    if hotel_in_db == None:
        raise HTTPException(status_code=404, detail="El Hotel no existe")

    hotel_out = HotelOut(**hotel_in_db.dict())

    return  hotel_out
Ejemplo n.º 5
0
async def create_new_hotel(newHotel: HotelOut):
    hotel_in_db = get_hotel(newHotel.nombre)
    if hotel_in_db == None:
        create_hotel(newHotel)
        return {"EL REGISTRO SE CREO EN LA BASE DE DATOS"}
    else:
        raise HTTPException(
            status_code=404,
            detail="EL REGISTRO NO SE PUEDE CREAR YA EXISTE EN LA BASE DE DATOS"
        )
Ejemplo n.º 6
0
async def auth_hotel(hotel_in: HotelIn):

    hotel_in_db = get_hotel(hotel_in.nombre)

    if hotel_in_db == None:
        raise HTTPException(status_code=404, detail="El Hotel no existe")

    if hotel_in_db.ubicacion != hotel_in.ubicacion:
        return  {"Autenticado": False}

    return  {"Autenticado": True}
Ejemplo n.º 7
0
async def make_transaction(transaction_in: TransactionIn):

    hotel_in_db = get_hotel(transaction_in.nombre)

    if hotel_in_db == None:
        raise HTTPException(status_code=404, detail="El hotel no existe")

    if hotel_in_db.totalHabitaciones < transaction_in.totalHabitaciones:
        raise HTTPException(status_code=400, detail=" ")

    hotel_in_db.totalHabitaciones = hotel_in_db.totalHabitaciones - transaction_in.reserva
    update_hotel(hotel_in_db)

    transaction_in_db = TransactionInDB(**transaction_in.dict(), totalHabs = hotel_in_db.totalHabitaciones)
    transaction_in_db = save_transaction(transaction_in_db)

    transaction_out = TransactionOut(**transaction_in_db.dict())

    return  transaction_out
Ejemplo n.º 8
0
async def get_room(hotelname: str):
    hotel_in_db = get_hotel(hotelname)
    if hotel_in_db == None:
        raise HTTPException(status_code=404, detail="El hotel no existe")
    hotel_out = HotelOut(**hotel_in_db.dict())
    return hotel_out
Ejemplo n.º 9
0
async def get_all_rooms():
    all_hotel = {}
    for key in get_all_hotel():
        hotel_out = HotelOut(**get_hotel(key).dict())
        all_hotel[hotel_out.hotelname] = hotel_out
    return all_hotel
Ejemplo n.º 10
0
async def check_hotel(check: HotelIn):
    hotel_in_db = get_hotel(check.nombre)
    if hotel_in_db == None:
        raise HTTPException(status_code=404,
                            detail="EL REGISTRO NO EXISTE EN LA BASE DE DATOS")
    return {"EL REGISTRO EXISTE EN LA BASE DE DATOS"}