public void PostHotelsAsyncTest() { Hotelbeds hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); Hotel[] hotels = { new Hotel { Code = "219199" } }; Accomodation[] accomodations = { new Accomodation { Guests = new Person[] { new Person { Age = 19, Name = "Nasty", Gender = Gender.Female, Type = PersonType.Adult } }, RoomsCount = 1 } }; var hotel_rooms = hotelbeds.PostHotelsAsync(hotels, TestUtils.From, TestUtils.To, accomodations) .Result; Assert.IsNotNull(hotel_rooms); }
public async Task <Adventure> GetResultAsync() { if (options == null || options.StartDate == null || options.FinishDate == null || options.Persons == null || options.AvailableHotels == null) { return(null); } var hotelbeds = new Hotelbeds(Hotelbeds.DEFAULT_KEY, Hotelbeds.DEFAULT_SECRET); var checkIn = options.StartDate.AddHours(options.AfterArrivalRelaxTime); var checkOut = options.FinishDate.AddHours(options.BeforeDepartureRelaxTime); var h = options.Hotel; if (h == null) { h = options.AvailableHotels.First(); } var rooms = await hotelbeds.PostHotelsAsync ( new Hotel[1] { h }, checkIn, checkOut, new Accomodation[1] { new Accomodation { Guests = options.Persons, RoomsCount = options.CountOfRooms } } ); if (rooms == null) { return(null); } var r = rooms.FirstOrDefault(); if (r == null) { return(null); } var occupancies = new Occupancy[1] { new Occupancy { Code = r.Code, Name = r.Name, CheckIn = checkIn, CheckOut = checkOut, RoomsCount = r.RoomsCount, Capacity = r.AdultsNumber + r.ChildrenNumber, OrderLink = r.OrderLink, Cost = r.Cost, Currency = r.Currency, Guests = options.Persons } }; h.Occupancies = occupancies; var weather = await new Openweathermap(Openweathermap.DEFAULT_KEY) .GetWeatherAsync(options.Destination.Location, (uint)DateTime.Now.AddDays(10).Subtract(options.StartDate).Days); var trips = await options.GetAvailableTripsAsync(); if (trips == null) { return(null); } var trip = trips.First(); return(new Adventure { Attractions = options.Attractions, Home = options.Origin, Destination = options.Destination, StartDate = options.StartDate, FinishDate = options.FinishDate, Hotels = new Hotel[1] { h }, Persons = options.Persons, Tickets = new Ticket[2] { trip.There, trip.Back }, Weather = weather, Currency = options.Currency }); }