public async Task <HotelSearchCityRS> HotelSearchByCityAsync(HotelSearchCityRQ request) { try { _LogService = new CommonServices.LogService(); _LogService.LogInfo("GTA/HotelSearchCityRQ", request); if (!IsValidRequest(request)) { return(null); } SearchHotelPriceRequest req = ConvertToSearchHotelPriceRequest(request); var xRequest = Serialize(req); var result = await SubmitAsync(xRequest); var response = Deserialize <SearchHotelPriceResponse>(result); var rsp = ConvertToHotelSearchCityRS(response, request); _LogService.LogInfo("GTA/HotelSearchCityRS", rsp); return(await rsp); } catch (Exception ex) { _LogService.LogException(ex, "Gta.HotelService.HotelSearchByCity"); return(new HotelSearchCityRS()); } }
public async Task <Hotel> GetGtaHotel(string code) { code = code.ToUpper(); string[] codes = code.Split("."); if (codes.Length != 2) { return(null); } try { _LogService = new CommonServices.LogService(); _LogService.LogInfo("GTA/SearchHotelRQ", $"Code: {code}"); SearchItemInformationRequest req = new SearchItemInformationRequest { Source = Source, RequestDetails = new Requestdetails { SearchItemInformationRequest = new Searchiteminformationrequest { ItemDestination = new Itemdestination { DestinationCode = codes[0], DestinationType = "city" }, ItemCode = codes[1], ItemType = "hotel", } } }; var xRequest = Serialize(req); var result = await SubmitAsync(xRequest); var response = Deserialize <SearchItemInformationResponse>(result); Hotel hotel = ConvertToHotel(response); if (hotel == null) { _LogService.LogInfo("GTA/SearchHotelRQ", "null"); return(null); } _LogService.LogInfo("GTA/SearchHotelRQ", hotel); return(hotel); } catch (Exception ex) { _LogService.LogException(ex, "Gta.GeoService.GetGtaCities"); return(null); } }
private async Task <List <City> > GetGtaCities(string countryCode) { countryCode = countryCode.ToUpper(); try { _LogService = new CommonServices.LogService(); List <string> codes = new List <string> { countryCode }; _LogService.LogInfo("GTA/SearchCityRQ", codes); SearchCountryRequest req = new SearchCountryRequest { Source = Source, RequestDetails = new Requestdetails { SearchCityRequest = new Searchcityrequest { CountryCode = countryCode } } }; var xRequest = Serialize(req); var result = await SubmitAsync(xRequest); var response = Deserialize <SearchCityResponse>(result); List <City> cities = new List <City>(); foreach (var city in response.ResponseDetails.SearchCityResponse.CityDetails) { if (cities.FirstOrDefault(c => c.Code == city.Code) == null) { cities.Add(new City { Code = city.Code.ToUpper(), Name = city.Value, CountryCode = countryCode }); } } _LogService.LogInfo("GTA/SearchCityRS", cities); return(cities); } catch (Exception ex) { _LogService.LogException(ex, "Gta.GeoService.GetGtaCities"); return(new List <City>()); } }