Exemplo n.º 1
0
        public HotelContentRS GetHotelInfo(HDSRequest request)
        {
            HotelInformationRequest hotelInfoRequest = new HotelInformationRequest();
            hotelInfoRequest = (HotelInformationRequest)commonHelper.GenerateBaseRequest(hotelInfoRequest, request);

            hotelInfoRequest.hotelId = (long)request.Hotels[0].Id;
            hotelInfoRequest.options = new hotelInfoOption[5];
            hotelInfoRequest.options[0] = new hotelInfoOption();
            hotelInfoRequest.options[0] = hotelInfoOption.HOTEL_DETAILS;        //hotel details
            hotelInfoRequest.options[1] = new hotelInfoOption();
            hotelInfoRequest.options[1] = hotelInfoOption.PROPERTY_AMENITIES;   //hotel amenities
            hotelInfoRequest.options[2] = new hotelInfoOption();
            hotelInfoRequest.options[2] = hotelInfoOption.HOTEL_IMAGES;         //hotel images
            hotelInfoRequest.options[3] = new hotelInfoOption();
            hotelInfoRequest.options[3] = hotelInfoOption.HOTEL_SUMMARY;        //hotel name and address
            hotelInfoRequest.options[4] = new hotelInfoOption();
            hotelInfoRequest.options[4] = hotelInfoOption.ROOM_TYPES;           //room info

                //submit soap request to expedia
            HotelInformationResponse hotelInfoResponse;
            try
            {
                serviceObjShop = new Expedia.HotelShoppingServiceReference.HotelServicesClient();
                hotelInfoResponse = serviceObjShop.getInformation(hotelInfoRequest);
            }
            catch (Exception e1)
            {
                HotelContentRS error = new HotelContentRS();
                error.Errors = new List<WarningAndError>();
                error.Errors.Add(new WarningAndError { Id = 9003, Message = "Error return from provider", DetailDescription = e1.ToString() });
                return error;
            }

            //do hotel content object mapping
            try
            {
                return objMapping.MappingHotelInfo(hotelInfoResponse);
            }
            catch(Exception e2)
            {
                HotelContentRS error = new HotelContentRS();
                error.Errors = new List<WarningAndError>();
                error.Errors.Add(new WarningAndError { Id = 9150, Message = "Hotel Conent mapping exception", DetailDescription = e2.ToString() });
                return error;
            }
        }
Exemplo n.º 2
0
        public HotelContentRS MappingHotelInfo(HotelInformationResponse rawRs)
        {
            HotelContentRS rs = new HotelContentRS();

            //EAN warning and error
            if (rawRs.EanWsError != null)
            {
                //error! something has happened
                rs.Errors = new List<WarningAndError>();
                WarningAndError error = helper.GenerateWarningAndError(9001, rawRs.EanWsError);
                rs.Errors.Add(error);
            }
            else
            {

                rs.Hotels = new List<HDSInterfaces.Hotel>();

                HDSInterfaces.Hotel hotel = new HDSInterfaces.Hotel();
                hotel.HotelInfo = new HotelInformation();
                hotel.HotelInfo.Id = rawRs.hotelId;

                //name and address
                if (rawRs.HotelSummary != null){
                    hotel.HotelInfo.Name = rawRs.HotelSummary.name;
                    hotel.HotelInfo.Address = helper.GenerateHotelAddress(rawRs.HotelSummary);

                    //rating
                    if (rawRs.HotelSummary.hotelRatingSpecified) { hotel.HotelInfo.StarRating = rawRs.HotelSummary.hotelRating; }
                    if (rawRs.HotelSummary.tripAdvisorRatingSpecified) { hotel.HotelInfo.TripAdvisorRating = rawRs.HotelSummary.tripAdvisorRating; }
                }

                //description and information
                if (rawRs.HotelDetails != null){
                    hotel.HotelInfo.HotelDescription = rawRs.HotelDetails.propertyDescription;
                    hotel.HotelInfo.AreaInfo         = rawRs.HotelDetails.areaInformation;
                    hotel.HotelInfo.RoomInfo         = rawRs.HotelDetails.roomInformation;
                    hotel.HotelInfo.DrivingDirection = rawRs.HotelDetails.drivingDirections;
                    hotel.HotelInfo.AdditionalInfo   = rawRs.HotelDetails.propertyInformation;

                    hotel.HotelInfo.PolicyInfo = new HotelPolicy{
                                                                    PolicyDescription  = rawRs.HotelDetails.hotelPolicy,
                                                                    CheckInInstruction = rawRs.HotelDetails.checkInInstructions,
                                                                    CheckInTime        = rawRs.HotelDetails.checkInTime,
                                                                    CheckOutTime       = rawRs.HotelDetails.checkOutTime,
                                                                };
                }

                //room info
                hotel.HotelInfo.RoomInfos = new List<RoomInfo>();
                if (rawRs.RoomTypes != null) {
                    if (rawRs.RoomTypes.size > 0){
                        foreach (Expedia.HotelShoppingServiceReference.RoomType roomType in rawRs.RoomTypes.RoomType){
                            RoomInfo room = new RoomInfo{
                                                                         Id = roomType.roomTypeId,
                                                                         Code = roomType.roomCode,
                                                                         Name = roomType.description,
                                                                         Description = roomType.descriptionLong
                                                                      };
                            hotel.HotelInfo.RoomInfos.Add(room);
                        }
                    }
                }

                //amenitity
                hotel.HotelInfo.Amenities = new List<HDSInterfaces.Amenity>();
                if (rawRs.PropertyAmenities != null){
                    if (rawRs.PropertyAmenities.size > 0){
                        foreach (PropertyAmenity rawAmenitity in rawRs.PropertyAmenities.PropertyAmenity){
                            HDSInterfaces.Amenity amenity = new Amenity { Id = rawAmenitity.amenityId, Description = rawAmenitity.amenity.Trim() };
                            hotel.HotelInfo.Amenities.Add(amenity);
                        }
                    }
                }

                //images
                hotel.HotelInfo.Images = new List<HDSInterfaces.HotelImage>();
                if (rawRs.HotelImages != null){
                    if (rawRs.HotelImages.size > 0){
                        foreach (Expedia.HotelShoppingServiceReference.HotelImage rawImage in rawRs.HotelImages.HotelImage){
                            hotel.HotelInfo.Images.Add(helper.GenerateHotelImage(rawImage));
                        }
                    }
                }

                rs.Hotels.Add(hotel);
            }

            return rs;
        }