Beispiel #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
Beispiel #2
0
async def auth_hotel(hotel_in: HotelIn):
    hotel_out.clear()
    hotel_in_db = get_hotel(hotel_in.ciudad)
    if hotel_in_db == None:
        raise HTTPException(status_code=404,
                            detail="No hay hoteles registrados")
    i = 0
    for clave in database_hotels.keys():
        a = get_hotel(clave)
        if a.ciudad == hotel_in_db.ciudad:
            if hotel_in.zona == a.zona:
                i += 1
                if (hotel_in.mes == "Marzo" or hotel_in.mes == "Abril"
                        or hotel_in.mes == "Mayo" or hotel_in.mes == "Junio"):
                    hotel_out.append(HotelOut(**a.dict()))

                if (hotel_in.mes == "Noviembre" or hotel_in.mes == "Diciembre"
                        or hotel_in.mes == "Enero"
                        or hotel_in.mes == "Febrero"):
                    hotel_out.append(HotelOut_a(**a.dict()))

                if (hotel_in.mes == "Julio" or hotel_in.mes == "Agosto"
                        or hotel_in.mes == "Septiembre"
                        or hotel_in.mes == "Octubre"):
                    hotel_out.append(HotelOut_b(**a.dict()))
    if i != 0:
        return hotel_out
    else:
        raise HTTPException(status_code=403)
Beispiel #3
0
async def list_hotels():
    hotels_in_db = get_all_hotels()
    hotels_out = []
    for hotel in hotels_in_db:
        hotel_out = HotelOut(**hotel.dict())
        hotels_out.append(hotel_out)

    return hotels_out
Beispiel #4
0
async def get_hotel(hotel_name: str):
    hotel_in_db = get_hotel_info(hotel_name)
    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
Beispiel #5
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
Beispiel #6
0
async def get_hoteles(ciudad: str):
    hotel_in_db = get_hotel(ciudad)
    if hotel_in_db == None:
        raise HTTPException(status_code=404,detail="No hay hoteles registrados en " + ciudad)
    i=0
    for clave in database_hotels.keys():
        if get_hotel(clave).ciudad == hotel_in_db.ciudad:
            i+=1
            hotel_out[i]= HotelOut(**get_hotel(clave).dict())
    return hotel_out
Beispiel #7
0
async def make_update(hotel_in: HotelInU):
    h_in_db = get_hotel(hotel_in.ciudad)
    if h_in_db == None:
        raise HTTPException(status_code=404,detail="No hay hoteles registrados en " + hotel_in.ciudad)
    for clave in database_hotels.keys():
        if get_hotel(clave).ciudad == hotel_in.ciudad:
            if get_hotel(clave).hotelname == hotel_in.hotelname:
                if get_hotel(clave).zona == hotel_in.zona:
                    get_hotel(clave).tarifa_inicial=hotel_in.tarifa_inicial
                    update_hotel(get_hotel(clave))
                    hotel_out = HotelOut(**get_hotel(clave).dict())
                    return hotel_out
    return "No hay hoteles " + hotel_in.hotelname + " al " + hotel_in.zona + " de " + hotel_in.ciudad
Beispiel #8
0
async def auth_hotel(hotel_in: HotelIn):
    hotel_out.clear()
    hotel_in_db = get_hotel(hotel_in.ciudad)
    if hotel_in_db == None:
        raise HTTPException(status_code=404, detail="El hotel no existe") 
    i=0
    for clave in database_hotels.keys():
        if get_hotel(clave).ciudad == hotel_in_db.ciudad:
            if hotel_in.zona == get_hotel(clave).zona:
                i+=1
                hotel_out[i]= HotelOut(**get_hotel(clave).dict())
    if i!=0:
        return hotel_out
    else:
        return "No hay hoteles en la zona " + hotel_in.zona + " de " + hotel_in.ciudad
Beispiel #9
0
async def get_hoteles(ciudad: str, mes: str):
    hotel_out.clear()
    hotel_in_db = get_hotel(ciudad)
    if hotel_in_db == None:
        raise HTTPException(status_code=404,
                            detail="No hay hoteles registrados en " + ciudad)
    for clave in database_hotels.keys():
        a = get_hotel(clave)
        if a.ciudad == hotel_in_db.ciudad:
            if (mes == "Marzo" or mes == "Abril" or mes == "Mayo"
                    or mes == "Junio"):
                hotel_out.append(HotelOut(**a.dict()))

            if (mes == "Noviembre" or mes == "Diciembre" or mes == "Enero"
                    or mes == "Febrero"):
                hotel_out.append(HotelOut_a(**a.dict()))

            if (mes == "Julio" or mes == "Agosto" or mes == "Septiembre"
                    or mes == "Octubre"):
                hotel_out.append(HotelOut_b(**a.dict()))
    return hotel_out
Beispiel #10
0
async def add_hotel(hotel_in: HotelInDB):
    update_hotel(hotel_in)
    hotel_out = HotelOut(**hotel_in.dict())
    return hotel_out
Beispiel #11
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