private SearchHotelsByIdRequest1 ConvertToTouricoHotelSearchRequest(HotelAvailabilityProviderReq request) { SearchHotelsByIdRequest sRequest = new SearchHotelsByIdRequest(); sRequest.CheckIn = request.CheckInDate; sRequest.CheckOut = request.CheckOutDate; sRequest.RoomsInformation = new RoomInfo[] { new RoomInfo { AdultNum = request.TotalAdults, ChildNum = 0, ChildAges = new ChildAge[] { new ChildAge { age = 0 } } } }; int i = 0; HotelIdInfo[] hIdInfo = new HotelIdInfo[request.HotelCodes.Count]; foreach (var hotelcode in request.HotelCodes) { HotelIdInfo hinfo = new HotelIdInfo(); hinfo.id = Convert.ToInt32(hotelcode); hIdInfo[i] = hinfo; i++; } sRequest.HotelIdsInfo = hIdInfo; SearchHotelsByIdRequest1 returnRequest = new SearchHotelsByIdRequest1(); returnRequest.AuthenticationHeader = Helper.GetTouricoAuthHeader(); returnRequest.request = sRequest; return(returnRequest); }
public override HotelAvailabilityProviderRes Execute(HotelAvailabilityProviderReq request) { if (request.LocationType == ServiceCatalogues.HotelCatalog.Enums.LocationTypes.Unknown) { //throw new ArgumentNullException(nameof(request.LocationType)); } if (request.CheckInDate <= DateTime.Today) { throw new ArgumentOutOfRangeException(nameof(request.CheckInDate)); } if (request.CheckInDate >= request.CheckOutDate) { throw new ArgumentOutOfRangeException(nameof(request.CheckOutDate)); } if (request.TotalAdults < 1) { throw new ArgumentOutOfRangeException(nameof(request.TotalAdults)); } using ( var touricoWorker = new TouricoWorker(pipelineManager: PipelineManager) ) { //convert request dto to Tourico search request SearchHotelsByIdRequest1 TouricoHotelRequest = ConvertToTouricoHotelSearchRequest(request); HotelAvailabilityProviderRes hotelSearchResults; try { var touricoRespone = touricoWorker.Execute <SearchHotelsByIdRequest1, SearchHotelsByIdResponse>(TouricoHotelRequest); if (touricoRespone == null) { throw new ProviderUnavailableException(ProviderTypes.Tourico.ToString(), $"No response to {nameof(SearchHotelsByIdRequest1)}.", null); } //convert response to HotelAvailabilityProviderRes hotelSearchResults = this.ConvertToProviderResponse(touricoRespone, request); } catch (TouricoProviderException e) { throw e; } return(hotelSearchResults); } }
public override HotelAvailabilityProviderRes Execute(HotelAvailabilityProviderReq request) { if (request.LocationType == LocationTypes.Unknown) { //throw new ArgumentNullException(nameof(request.LocationType)); } if (request.CheckInDate <= DateTime.Today) { throw new ArgumentOutOfRangeException(nameof(request.CheckInDate)); } if (request.CheckInDate >= request.CheckOutDate) { throw new ArgumentOutOfRangeException(nameof(request.CheckOutDate)); } if (request.TotalAdults < 1) { throw new ArgumentOutOfRangeException(nameof(request.TotalAdults)); } using ( var touricoWorker = new TouricoWorker(pipelineManager: PipelineManager) ) { //convert request dto to Tourico search request SearchHotelsByIdRequest1 TouricoHotelRequest = ConvertToTouricoHotelSearchRequest(request); HotelAvailabilityProviderRes hotelSearchResults; try { var touricoRespone = touricoWorker.Execute <SearchHotelsByIdRequest1, SearchHotelsByIdResponse>(TouricoHotelRequest); //convert response to HotelAvailabilityProviderRes hotelSearchResults = this.ConvertToProviderResponse(touricoRespone, request); } catch (Exception ex) { throw ex; } return(hotelSearchResults); } }
private SearchHotelsByIdRequest1 ConvertToTouricoHotelSearchRequest(HotelAvailabilityProviderReq request) { SearchHotelsByIdRequest sRequest = new SearchHotelsByIdRequest(); sRequest.CheckIn = request.CheckInDate; sRequest.CheckOut = request.CheckOutDate; sRequest.RoomsInformation = new RoomInfo[] { new RoomInfo { AdultNum = request.TotalAdults, ChildNum = 0, ChildAges = new ChildAge[] { new ChildAge { age = 0 } } } }; int i = 0; HotelIdInfo[] hIdInfo = new HotelIdInfo[request.HotelCodes.Count]; foreach (var hotelcode in request.HotelCodes) { HotelIdInfo hinfo = new HotelIdInfo(); hinfo.id = Convert.ToInt32(hotelcode); hIdInfo[i] = hinfo; i++; } sRequest.HotelIdsInfo = hIdInfo; SearchHotelsByIdRequest1 returnRequest = new SearchHotelsByIdRequest1(); returnRequest.request = sRequest; //Temp Add Auth Header to Test: musanka var authHeader = new AuthenticationHeader(); //TODO: Move to config setting authHeader.LoginName = "Tra105"; authHeader.Password = "******"; returnRequest.AuthenticationHeader = authHeader; return(returnRequest); }