Example #1
0
        private HotelSearchCityRS ConvertToResponse(HotelListRs rs,
                                                    HotelSearchCityRQ request, string requestKey)
        {
            HotelSearchCityRS response = new HotelSearchCityRS
            {
                CheckIn     = request.CheckIn,
                CheckOut    = request.CheckOut,
                LocationId  = request.LocationId,
                Supplier    = "EAN",
                Occupancies = request.Occupancies.ToList(),
                Locale      = request.Locale,
                Currency    = request.Currency,
                Hotels      = rs.HotelListResponse.HotelList.HotelSummary.ToList().Select(h =>
                                                                                          new HotelRS
                {
                    Id         = h.hotelId.ToString(),
                    Name       = h.name,
                    Address    = h.address1,
                    Latitude   = h.latitude,
                    Longitude  = h.longitude,
                    Location   = h.locationDescription,
                    ShortDesc  = h.shortDescription,
                    StarRating = (decimal)h.hotelRating,
                    Thumbnail  = $"https://i.travelapi.com{h.thumbNailUrl.Replace("t.jpg", "s.jpg")}",
                    CurrCode   = h.rateCurrencyCode,
                    RateFrom   = (decimal)h.lowRate,
                    RateTo     = (decimal)h.highRate,
                    HotelRooms = h.RoomRateDetailsList.RoomRateDetails.Select(rm =>
                                                                              new RoomListRS
                    {
                        RoomTypeCode   = rm.roomTypeCode.ToString(),
                        RateCode       = rm.rateCode.ToString(),
                        PromoDesc      = rm.RateInfos.RateInfo.promoDescription,
                        Allotment      = rm.RateInfos.RateInfo.currentAllotment,
                        ChargeableRate = new ChargeableRateRS
                        {
                            Currency            = rm.RateInfos.RateInfo.ChargeableRateInfo.currencyCode,
                            MaxNightlyRate      = Convert.ToDecimal(rm.RateInfos.RateInfo.ChargeableRateInfo.maxNightlyRate),
                            TotalCommissionable = Convert.ToDecimal(rm.RateInfos.RateInfo.ChargeableRateInfo.commissionableUsdTotal),
                            TotalSurcharge      = Convert.ToDecimal(rm.RateInfos.RateInfo.ChargeableRateInfo.surchargeTotal),
                            Total = Convert.ToDecimal(rm.RateInfos.RateInfo.ChargeableRateInfo.total),
                        }
                    }).OrderBy(r => r.ChargeableRate.Total).ToList()
                }
                                                                                          ).ToList()
            };

            if (rs.HotelListResponse.moreResultsAvailable)
            {
                response.CacheKey      = rs.HotelListResponse.cacheKey;
                response.CacheLocation = rs.HotelListResponse.cacheLocation;
                response.RequestKey    = requestKey;
            }

            return(response);
        }
Example #2
0
        private HotelSearchCityRS ConvertToResponse(HotelListRs rs,
                                                    HotelGetMoreRQ request)
        {
            HotelSearchCityRS response = new HotelSearchCityRS
            {
                Supplier = "EAN",
                Locale   = request.Locale,
                Currency = request.Currency,
                Hotels   = rs.HotelListResponse.HotelList.HotelSummary.ToList().Select(h =>
                                                                                       new HotelRS
                {
                    Id         = h.hotelId.ToString(),
                    Name       = h.name,
                    Address    = h.address1,
                    Latitude   = h.latitude,
                    Longitude  = h.longitude,
                    Location   = h.locationDescription,
                    ShortDesc  = h.shortDescription,
                    StarRating = (decimal)h.hotelRating,
                    Thumbnail  = h.thumbNailUrl,
                    CurrCode   = h.rateCurrencyCode,
                    RateFrom   = (decimal)h.lowRate,
                    RateTo     = (decimal)h.highRate
                }
                                                                                       ).ToList()
            };

            if (rs.HotelListResponse.moreResultsAvailable)
            {
                response.CacheKey      = rs.HotelListResponse.cacheKey;
                response.CacheLocation = rs.HotelListResponse.cacheLocation;
                response.RequestKey    = request.RequestKey;
            }

            return(response);
        }