public HotelAvailabilityRS GetHotelAvailability(HDSRequest request) { HotelRoomAvailabilityRequest rawRq = new HotelRoomAvailabilityRequest(); rawRq = (HotelRoomAvailabilityRequest)commonHelper.GenerateBaseRequest(rawRq, request); //stay date rawRq.arrivalDate = request.StayDate.GetCheckInUSFormat(); rawRq.departureDate = request.StayDate.GetCheckOutUSFormat(); //hotel rawRq.hotelId = (long)request.Hotels[0].Id; //room and num adults-children rawRq.RoomGroup = commonHelper.GenerateRoomGroup(request.Itineraries); //include details rawRq.includeDetails = true; rawRq.includeDetailsSpecified = true; rawRq.includeRoomImages = true; rawRq.includeRoomImagesSpecified = true; //submit soap request to expedia HotelRoomAvailabilityResponse rawRs; try { serviceObjShop = new Expedia.HotelShoppingServiceReference.HotelServicesClient(); rawRs = serviceObjShop.getAvailability(rawRq); } catch (Exception e1) { HotelAvailabilityRS error = new HotelAvailabilityRS(); error.Errors = new List<WarningAndError>(); error.Errors.Add(new WarningAndError { Id = 9003, Message = "Error return from provider", DetailDescription = e1.ToString() }); return error; } //do hotel availability mapping try { return objMapping.MappingHotelAvailability(rawRs); } catch (Exception e2) { HotelAvailabilityRS error = new HotelAvailabilityRS(); error.Errors = new List<WarningAndError>(); error.Errors.Add(new WarningAndError { Id = 9120, Message = "Hotel Availability mapping exception", DetailDescription = e2.ToString() }); return error; } }
public HotelAvailabilityRS MappingHotelAvailability(HotelRoomAvailabilityResponse rawRs) { HotelAvailabilityRS rs = new HotelAvailabilityRS(); //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 { //init hotel rs.Hotel = new HDSInterfaces.Hotel(); //hotel address info rs.Hotel.HotelInfo = new HotelInformation(); rs.Hotel.HotelInfo.Id = rawRs.hotelId; rs.Hotel.HotelInfo.Name = rawRs.hotelName; rs.Hotel.HotelInfo.Address = new Address(); rs.Hotel.HotelInfo.Address.Street1 = rawRs.hotelAddress; rs.Hotel.HotelInfo.Address.City = new City { Name = rawRs.hotelCity }; rs.Hotel.HotelInfo.Address.Country = new Country { Code = rawRs.hotelCountry }; //room rs.Hotel.Rooms = new List<HDSInterfaces.Room>(); foreach (HotelRoomResponse rawRoom in rawRs.HotelRoomResponse) { HDSInterfaces.Room room = new HDSInterfaces.Room(); //room cancellation room.CancellationPolicy = new CancellationPolicy { CancellationPolicyDescription = rawRoom.cancellationPolicy }; room.CancellationPolicy.IsNonRefundable = rawRoom.nonRefundable; //room info room.Name = rawRoom.rateDescription; room.Description = rawRoom.rateDescription; room.RoomInfo = new RoomInfo(); //room promotion if (rawRoom.promoDescription != null){ room.Promotions = new List<Promotion>(); room.Promotions.Add(new Promotion { Code = rawRoom.promoId, Description = rawRoom.promoDescription }); } //room bedding config if (rawRoom.BedTypes != null) room.RoomInfo.BeddingDescription = rawRoom.BedTypes.BedType[0].description; //room images if (rawRoom.RoomImages != null){ room.RoomInfo.Images = new List<HDSInterfaces.RoomImage>(); room.RoomInfo.Images.Add(new HDSInterfaces.RoomImage { URL = rawRoom.RoomImages.RoomImage[0].url }); } //value adds if (rawRoom.ValueAdds != null){ room.ValueAdds = new List<RoomValueAdd>(); foreach (valueAdd rawValueAdd in rawRoom.ValueAdds.ValueAdd){ room.ValueAdds.Add(new RoomValueAdd { Id = rawValueAdd.id, Description = rawValueAdd.description }); } } //room rate total and nightly room.Rates = helper.GenerateRoomRate(rawRoom.RateInfo); rs.Hotel.Rooms.Add(room); } } return rs; }