private HotelAvailabilityProviderRes ConvertToProviderResponse(AvailabilityRS request) { HotelAvailabilityProviderRes hotelResultRS = new HotelAvailabilityProviderRes(); var hotels = new List <HotelSearchResultItem>(); if (request?.hotels?.hotels != null && request.hotels.hotels.Any()) { foreach (var htl in request.hotels.hotels) { var searchResult = new HotelSearchResultItem() { HotelInfo = new HotelInfo() { HotelName = htl.name, HotelCode = htl.code.ToString(), Description = htl.zoneCode + ", " + htl.zoneName, Rating = Convert.ToInt16(htl.categoryName.Split(HotelBedsConstants.SpaceSeperator)[0]), PropertyInformation = new HotelPropertyDetail() { Latitude = Convert.ToDecimal(htl.latitude), Longitude = Convert.ToDecimal(htl.longitude) }, }, Price = new TE.DataAccessLayer.Models.TMoney() { Amount = htl.minRate, Currency = new TE.DataAccessLayer.Models.TCurrency() { CurrencyCode = htl.currency } } }; hotels.Add(searchResult); } hotelResultRS.Hotels = hotels; } else { hotelResultRS.Hotels = null; } return(hotelResultRS); }
/// <summary> /// Searchs for hotels /// </summary> /// <returns></returns> public async Task <IEnumerable <HotelSearchResultItem> > Search(string city, DateTime date) { var result = new List <HotelSearchResultItem>(); var rnd = new Random(); var resultItemCount = rnd.Next(5) + 1; for (int i = 0; i < resultItemCount; i++) { var item = new HotelSearchResultItem() { Name = $"Hotel {i + 1}", Price = 1000 + (100 * rnd.Next(15)), }; result.Add(item); await Task.Delay(100); } return(result); }
private HotelAvailabilityProviderRes ConvertToProviderResponse(AvailabilityRS request) { HotelAvailabilityProviderRes hotelResultRS = new HotelAvailabilityProviderRes(); var hotels = new List<HotelSearchResultItem>(); if (request?.hotels?.hotels != null && request.hotels.hotels.Any()) { foreach (var htl in request.hotels.hotels) { var searchResult = new HotelSearchResultItem() { HotelInfo = new HotelInfo() { HotelName = htl.name, HotelCode = htl.code.ToString(), Description = htl.zoneCode + ", " + htl.zoneName, Rating = Convert.ToInt16(htl.categoryName.Split(HotelBedsConstants.SpaceSeperator)[0]), PropertyInformation = new HotelPropertyDetail() { Latitude = Convert.ToDecimal(htl.latitude), Longitude = Convert.ToDecimal(htl.longitude) }, }, Price = new TE.DataAccessLayer.Models.TMoney() { Amount = htl.minRate, Currency = new TE.DataAccessLayer.Models.TCurrency() { CurrencyCode = htl.currency } } }; hotels.Add(searchResult); } hotelResultRS.Hotels = hotels; } else hotelResultRS.Hotels = null; return hotelResultRS; }
private HotelAvailabilityProviderRes ConvertToProviderResponse(SearchHotelsByIdResponse response, HotelAvailabilityProviderReq request) { HotelAvailabilityProviderRes providerResp; if (response.SearchHotelsByIdResult.HotelList.Length == 0) { throw new ApplicationException("AvailabilityOptions is null."); } providerResp = new HotelAvailabilityProviderRes(); var hotels = new List <HotelSearchResultItem>(); foreach (var hotel in response.SearchHotelsByIdResult.HotelList) { var hotelResult = new HotelSearchResultItem(); hotelResult.HotelInfo = new TE.Core.ServiceCatalogues.HotelCatalog.Dtos.HotelInfo(); hotelResult.HotelInfo.Rating = Convert.ToInt16(hotel.starsLevel); //tourico returns in decimal to imply 3.5, 4.5 etc hotelResult.HotelInfo.RatingType = RatingTypes.Star; hotelResult.HotelInfo.Address = new Shared.Dtos.AddressDto() { Address1 = hotel.Location.address, Address2 = "", City = hotel.Location.city, Zip = "" }; hotelResult.HotelInfo.HotelCode = hotel.hotelId.ToString(); hotelResult.HotelInfo.HotelChainCode = hotel.brandId.ToString(); hotelResult.HotelInfo.HotelName = hotel.name; hotelResult.HotelInfo.CityCode = hotel.Location.searchingCity; //? city code hotelResult.HotelInfo.Thumbnails = hotel.thumb; //Currency and Currency Code if (hotel.minAverPublishPrice > 0) { hotelResult.Price = new TMoney { Amount = hotel.minAverPublishPrice, Currency = new TCurrency { CurrencyCode = hotel.currency } }; } hotelResult.HotelInfo.PhoneNumber = null; // Available only in GetHotelDetailsV3 hotelResult.HotelInfo.Provider = DataAccessLayer.Enums.ProviderTypes.Tourico; //lat and long hotelResult.HotelInfo.Location = new GeoLocation { Latitude = hotel.Location.latitude, Longitude = hotel.Location.longitude }; hotelResult.HotelInfo.SpecialOffers = null; hotelResult.HotelInfo.Amenities = null; // Available only in GetHotelDetailsV3 //Room Type info hotelResult.HotelInfo.SpecialOffers = hotel.RoomTypes.ToString(); // musanka : remove assigning to SpecialOffers property hotels.Add(hotelResult); } providerResp.Hotels = hotels; return(providerResp); }