// log XML req and rsp for provider public static void LogSearchProviderReq(HotelSearchRequest SearchReq, string SearchId) { string path = MainPath + @"\TBOLogs\" + DateTime.UtcNow.Date.ToString("dd_MM_yyyy") + @"\" + SearchId + @"\SearchRequest\"; Directory.CreateDirectory(path); path = path + "HotelSearchRequest.txt"; try { XmlSerializer xmlSerializer = new XmlSerializer(SearchReq.GetType()); using (StreamWriter streamwriter = new StreamWriter(path, append: false)) { xmlSerializer.Serialize(streamwriter, SearchReq); streamwriter.Close(); } } catch (FileNotFoundException Ex) { throw new LoggerException(LoggerErrorCodes.LoggerFileNotFound, LoggerErrorCodes.LoggerFileNotFound + " -This path (" + path + ") doesn't exist with file name " + Ex.FileName + " .", Ex.Message); } catch (IOException Ex) { throw new LoggerException(LoggerErrorCodes.LoggerFileINProcess, LoggerErrorCodes.LoggerFileINProcess + " -This Logger File (" + path + ") in another process you can not access it right now.", Ex.Message); } catch (Exception Ex) { throw new LoggerException(LoggerErrorCodes.FailedLogIntoLogger, LoggerErrorCodes.FailedLogIntoLogger + " -Failed Log Into Logger with path (" + path + ").", Ex.Message); } }
public static HotelSearchResponse Search(HotelSearchRequest req, string SID) { var UName = ConfigurationSettings.AppSettings["TBOUserName"]; var UPass = ConfigurationSettings.AppSettings["TBOPassword"]; IHotelService proxy = TBOCredentials.CreateProxy(); req.Credentials = new AuthenticationData() { UserName = UName, Password = UPass }; ProviderLogger.LogSearchProviderReq(req, SID); HotelSearchResponse resp = new HotelSearchResponse(); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); resp = proxy.HotelSearch(req); stopWatch.Stop(); TimeSpan ts1 = stopWatch.Elapsed; ProviderLogger.LogSearchProviderRsp(resp, SID, ts1.ToString()); return(resp); }
//map general req to TBO req public static HotelSearchRequest MapSearchReq(SearchReq searchReq) { List <TBO.WSDL.hotelServiceRef.RoomGuest> guests = new List <TBO.WSDL.hotelServiceRef.RoomGuest>(); foreach (var item in searchReq.RoomGuests) { guests.Add(new TBO.WSDL.hotelServiceRef.RoomGuest() { AdultCount = item.AdultCount, ChildAge = item.ChildAge, ChildCount = item.ChildCount }); } HotelSearchRequest TBOReq = new HotelSearchRequest { CheckInDate = searchReq.CheckInDate.Date, CheckOutDate = searchReq.CheckOutDate.Date, CityId = searchReq.CityId, CityName = searchReq.CityName, CountryName = searchReq.CountryName, GuestNationality = searchReq.GuestNationality, NoOfRooms = searchReq.NoOfRooms, RoomGuests = guests.ToArray(), Filters = new Filters { HotelCodeList = string.Join(",", searchReq.HotelCodeList.ToArray()) } }; return(TBOReq); }
private async void frmTerminiDetalji_Load(object sender, EventArgs e) { await LoadHoteli(); if (!_id.HasValue) { txtCijena.Text = "0"; txtPopust.Text = "0"; txtAkcijskaCijena.Text = "0"; pickerOd.MinDate = System.DateTime.Now; pickerDo.MinDate = System.DateTime.Now; btnObrisi.Visible = false; btnPrint.Visible = false; btnKarte.Visible = false; panel1.Visible = false; } if (_id.HasValue) { btnObrisi.Visible = true; btnPrint.Visible = true; btnKarte.Visible = true; panel1.Visible = true; await LoadZaradaiKarte(); var termin = await _termini.GetById <Models.Termin>(_id); pickerOd.Value = termin.DatumPolaska; pickerDo.Value = termin.DatumDolaska; chcboxAktivan.Checked = termin.AktivanTermin; txtPopust.Text = termin.Popust.ToString(); txtCijena.Text = termin.Cijena.ToString(); txtAkcijskaCijena.Text = termin.CijenaPopust.ToString(); //var t = await _termini.GetById<Models.Termin>(_id); var search = new HotelSearchRequest { GradId = termin.GradId }; var result = await _hoteli.Get <List <Models.Hotel> >(search); cmbHotel.DisplayMember = "Naziv"; cmbHotel.ValueMember = "Id"; cmbHotel.DataSource = result; cmbHotel.SelectedValue = termin.HotelId; //radi novog itema u cmblisti //implementirati update } }
private async void doSearch_Click(object sender, RoutedEventArgs e) { try { prog.Text = "working..."; ServiceReference1.Service1Client service = new ServiceReference1.Service1Client(); service.ClientCredentials.UserName.UserName = "******"; service.ClientCredentials.UserName.Password = "******"; ServiceReference1.HotelSearchRequest hr = new HotelSearchRequest(); hr.destination = destination.Text; hr.date = DateTime.Now.AddDays(2); ServiceReference1.hotelsummary[] hotels = await service.GetHotelsAsync(hr); text.Text = ""; foreach (var h in hotels) { text.Text += String.Format("{0},{1},{2}", h.name, h.address1, h.city) + "\n"; } if (searchResultCollectionList == null) { searchResultCollectionList = new SearchResultCollectionList(); } SearchResultCollectionList.ItemsSource = hotels.ToList(); prog.Text = ""; } catch (Exception exp) { prog.Text = ""; if (exp.InnerException != null) { text.Text = exp.InnerException.Message; } else if (exp != null) { text.Text = exp.Message; } else { text.Text = "unknow error"; } } }
private HotelSearchRequest CreateSearchRequest() { var hotelSearchParameters = new HotelSearchRequest(); hotelSearchParameters.CheckInDate = DateTime.Now.AddMonths(6); hotelSearchParameters.CheckOutDate = DateTime.Now.AddMonths(6).AddDays(1); hotelSearchParameters.CityCode = "3CHA"; hotelSearchParameters.CountryCode = "TH"; hotelSearchParameters.Rooms.Add(new RoomSearchParameters { Adult = 1 }); return(hotelSearchParameters); }
public JsonResult Get(string longitude, string latitude, string radius, string startDate) { var searchRequest = new HotelSearchRequest() { Longitude = longitude, Latitude = latitude, Radius = Convert.ToInt32(radius), StartDate = DateTime.Now }; var hotelService = new HotelBedsHotelService(); var searchResponse = hotelService.Search(searchRequest); return(Json(searchResponse)); }
// GET api/values public HotelSearchResponse Get(string latitude, string longitude, int radius, string startDate) { var hotelRequest = new HotelSearchRequest() { Radius = radius, StartDate = DateTime.ParseExact(startDate, "yyyy-MM-dd", CultureInfo.InvariantCulture), Latitude = latitude, Longitude = longitude }; var hotelService = new HotelBedsHotelService(); var response = hotelService.Search(hotelRequest); return(response); }
private async Task LoadHoteli() { var destinacija = await _destinacije.GetById <Models.Destinacija>(_destinacijaid); var search = new HotelSearchRequest() { GradId = destinacija.GradId }; var result = await _hoteli.Get <List <Models.Hotel> >(search); result.Insert(0, new Models.Hotel()); cmbHotel.DisplayMember = "Naziv"; cmbHotel.ValueMember = "Id"; cmbHotel.DataSource = result; }
private async void btnPretraga_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { var search = new HotelSearchRequest() { Naziv = txtNaziv.Text, GradId = int.Parse(cmbGrad.SelectedValue.ToString()) }; var result = await _hoteli.Get <List <Models.Hotel> >(search); dgvHoteli.AutoGenerateColumns = false; dgvHoteli.DataSource = result; } }
public dynamic SearchHotel(HotelSearchRequest _Hotel) { HotelSearchList _Searchlist = new HotelSearchList(); try { _Hotel.EndUserIp = IPAddress; _Hotel.TokenId = BLFunction.GetTokenID(); var jsonObject = JsonConvert.SerializeObject(_Hotel); String QualifiedUrl = Baseurl + "BookingEngineService_Hotel/hotelservice.svc/rest/GetHotelResult"; var result = APIHotel.Instance().GetResponse(QualifiedUrl, Verbs.POST, jsonObject); if (result != null) { _Searchlist = JsonConvert.DeserializeObject <HotelSearchList>(result); } } catch (Exception ex) { string msg = ex.Message; } return(_Searchlist); }
protected void btnSubmit_Click(object sender, EventArgs e) { try { if (Page.IsValid) { if (drpCountry.SelectedValue != "0" && drpCity.SelectedValue != "0") { CountryCode = drpCountry.SelectedValue; CityId = drpCity.SelectedValue; } else if (drpTopCity.SelectedValue != "0") { CityId = drpTopCity.SelectedValue.Split(',')[0]; CountryCode = drpTopCity.SelectedValue.Split(',')[1]; } else { BLFunction.ShowAlert(this, "Please select Destination place", ResponseType.WARNING); return; } if (String.IsNullOrEmpty(txtCheckIn.Text.Trim())) { BLFunction.ShowAlert(this, "Please select date", ResponseType.WARNING); txtCheckIn.Focus(); return; } else if (drpGuestNationality.SelectedIndex == 0) { BLFunction.ShowAlert(this, "Please select guest Nationality", ResponseType.WARNING); return; } String NoOfNights = drpNight.SelectedValue; String CheckInDate = txtCheckIn.Text.Trim(); String PreferredCurrency = ""; String GuestNationality = drpGuestNationality.SelectedValue; Session["GuestNationality"] = GuestNationality; String NoOfRooms = drpRooms.SelectedValue; int NoOfAdults = Convert.ToInt32(drpAdults.SelectedValue); int NoOfChild = Convert.ToInt32(drpChilds.SelectedValue); String PreferredHotel = ""; string ratings = txtRatings.Text; int MaxRating = Convert.ToInt32(ratings.Split(',')[1]); int MinRating = Convert.ToInt32(ratings.Split(',')[0]); bool IsNearBySearchAllowed = chkNearBy.Checked; HotelSearchRequest _Hotel = new HotelSearchRequest(); _Hotel.CheckInDate = CheckInDate; _Hotel.CityId = CityId; _Hotel.CountryCode = CountryCode; _Hotel.GuestNationality = GuestNationality; _Hotel.IsNearBySearchAllowed = IsNearBySearchAllowed; _Hotel.MaxRating = MaxRating; _Hotel.MinRating = MinRating; _Hotel.NoOfNights = NoOfNights; _Hotel.NoOfRooms = NoOfRooms; Session["NoOfRooms"] = NoOfRooms; _Hotel.PreferredCurrency = PreferredCurrency; _Hotel.PreferredHotel = PreferredHotel; RoomGuest _guest = new RoomGuest(); _guest.NoOfAdults = NoOfAdults; _guest.NoOfChild = NoOfChild; if (NoOfChild > 0) { while (NoOfChild > 0) { _guest.ChildAge.Add(15); NoOfChild--; } } _Hotel.RoomGuests.Add(_guest); Session["RoomGuests"] = _Hotel.RoomGuests; HotelSearchList _SearchResult = DataProviderWrapper.Instance.SearchHotel(_Hotel); rptHotels.DataSource = null; if (_SearchResult.HotelSearchResult.Error.ErrorCode > 0) { BLFunction.ShowAlert(this, _SearchResult.HotelSearchResult.Error.ErrorMessage, ResponseType.WARNING); return; } if (_SearchResult?.HotelSearchResult?.HotelResults != null) { Session["TraceId"] = _SearchResult.HotelSearchResult.TraceId; rptHotels.DataSource = _SearchResult.HotelSearchResult.HotelResults; } rptHotels.DataBind(); pnlHotelList.Visible = true; rptHotels.Focus(); } else { BLFunction.ShowAlert(this, "Invalid page request.Please Reload the page again", ResponseType.WARNING); return; } } catch (Exception ex) { string message = ex.Message; BLFunction.ShowAlert(this, message, ResponseType.WARNING); return; } }
public HotelSearchResponse GetHotels(HotelSearchRequest objRequest) { MarketPropertyContent objMarketPropertyContent = null; List <PropertyRoomContent> lstPropertyRoomContent = new List <PropertyRoomContent>(); PropertyRoomContent objPropertyRoomContent; var objHotelSearchResponse = new HotelSearchResponse(); try { var SiteBaseUrl = ConfigurationManager.AppSettings["SiteBaseUrl"].ToString(); var objHotelSearchRequest = new Model.ServiceModel.HotelSearchRequest.HotelSearchRequest(); objHotelSearchRequest.request = new Model.ServiceModel.HotelSearchRequest.Request(); objHotelSearchRequest.request.__type = "SearchRequest"; objHotelSearchRequest.request.AppKey = "IAPTestWebsite"; objHotelSearchRequest.request.Criteria = new Model.ServiceModel.HotelSearchRequest.Criteria(); objHotelSearchRequest.request.Criteria.__type = "HotelCriteria"; if (!string.IsNullOrEmpty(objRequest.Market)) { var lstMarkets = _iCategryService.GetMarkets(); var objMarket = lstMarkets.Where(item => item.Description.ToLower().Contains(objRequest.Market.ToLower())).FirstOrDefault(); if (objMarket != null) { string[] locations = new string[objMarket.BranchList.Count]; for (int i = 0; i < objMarket.BranchList.Count; i++) { locations[i] = objMarket.BranchList[i].Code; } objHotelSearchRequest.request.Criteria.Locations = locations; //Need to change this based on the design //objMarketPropertyContent=_iMarketingService.GetMarketPropertyContents(objMarket.Code); //foreach(var item in objMarketPropertyContent.PropertyContents) //{ // objPropertyRoomContent = _iMarketingService.GetPropertyRoomContents(item.PropertyCode); // lstPropertyRoomContent.Add(objPropertyRoomContent); //} } else { return(objHotelSearchResponse); } } else if (!string.IsNullOrEmpty(objRequest.Property)) { string[] locations = new string[1]; var lstBranches = _iCategryService.GetBranches(); if (objRequest.Property.Length == 3) { var objBranch = lstBranches.Where(item => item.Code.ToLower() == objRequest.Property.ToLower()).FirstOrDefault(); if (objBranch != null) { locations[0] = objBranch.Code; //Need to change this based on the design //objPropertyRoomContent = _iMarketingService.GetPropertyRoomContents(objBranch.Code); //lstPropertyRoomContent.Add(objPropertyRoomContent); } else { objBranch = lstBranches.Where(item => item.Name.ToLower() == objRequest.Property.ToLower()).FirstOrDefault(); if (objBranch != null) { locations[0] = objBranch.Code; } else { return(objHotelSearchResponse); } } } else { var objBranch = lstBranches.Where(item => item.Name.ToLower().Contains(objRequest.Property.ToLower())).FirstOrDefault(); if (objBranch != null) { locations[0] = objBranch.Code; //Need to change this based on the design //objPropertyRoomContent = _iMarketingService.GetPropertyRoomContents(objBranch.Code); //lstPropertyRoomContent.Add(objPropertyRoomContent); } else { return(objHotelSearchResponse); } } objHotelSearchRequest.request.Criteria.Locations = locations; } objHotelSearchRequest.request.Criteria.EndDate = objRequest.CheckoutDate.ToString("yyyy-MM-dd"); objHotelSearchRequest.request.Criteria.HotelRoomDetails = new Model.ServiceModel.HotelSearchRequest.Hotelroomdetail[1]; objHotelSearchRequest.request.Criteria.HotelRoomDetails[0] = new Model.ServiceModel.HotelSearchRequest.Hotelroomdetail(); objHotelSearchRequest.request.Criteria.HotelRoomDetails[0].Adults = 2; objHotelSearchRequest.request.Criteria.HotelRoomDetails[0].Children = 0; objHotelSearchRequest.request.Criteria.HotelRoomDetails[0].__type = "HotelRoomDetail"; objHotelSearchRequest.request.Criteria.LengthOfStays = new int[1]; objHotelSearchRequest.request.Criteria.LengthOfStays[0] = (objRequest.CheckoutDate - objRequest.CheckinDate).Days; objHotelSearchRequest.request.Criteria.StartDate = objRequest.CheckinDate.ToString("yyyy-MM-dd"); objHotelSearchRequest.request.GroupCode = ""; objHotelSearchRequest.request.Requestor = "Galaxy Test Harness"; objHotelSearchRequest.request.SecurityToken = ""; objHotelSearchRequest.request.SelectionAttributes = new Model.ServiceModel.HotelSearchRequest.Selectionattribute[1]; objHotelSearchRequest.request.SelectionAttributes[0] = new Model.ServiceModel.HotelSearchRequest.Selectionattribute(); objHotelSearchRequest.request.SelectionAttributes[0].__type = "Attr"; objHotelSearchRequest.request.SelectionAttributes[0].Id = 0; objHotelSearchRequest.request.SelectionAttributes[0].Name = "pruning"; objHotelSearchRequest.request.SelectionAttributes[0].Value = "LowestPromoAndAllOtherQuotes"; objHotelSearchRequest.request.TransactionStartTime = DateTime.UtcNow; var response = ServiceBridge <Model.ServiceModel.HotelSearchRequest.HotelSearchRequest, Model.ServiceModel.HotelSearchResponse.HotelSearchResponse> .Run(objHotelSearchRequest, ServiceTypes.HotelSearch, HttpMethod.Post); objHotelSearchResponse.properties = new List <Property>(); Property objProperty; Room objRoom; if (response != null) { foreach (var productType in response.ProductTypes) { foreach (var product in productType.Products) { objProperty = new Property(); objProperty.Name = product.Name; if (objMarketPropertyContent != null) { var ojPropertyContent = objMarketPropertyContent.PropertyContents.Where(p => p.PropertyName == product.Name).FirstOrDefault(); if (ojPropertyContent != null) { objProperty.Summary = ojPropertyContent.Summary; objProperty.ImageUrl = ojPropertyContent.ImageUrl; } } //Need to change this based on the design objPropertyRoomContent = _iMarketingService.GetPropertyRoomContents(product.Location.Code); lstPropertyRoomContent.Add(objPropertyRoomContent); var lstRoomContents = lstPropertyRoomContent.Where(p => p.PropertyName == product.Name).FirstOrDefault(); objProperty.Rooms = new List <Room>(); foreach (var sku in product.SKUs) { objRoom = new Room(); objRoom.Name = sku.Name; if (sku.Quotes[0] != null) { objRoom.AvgRate = sku.Quotes[0].Avg; } var objRoomContent = lstRoomContents.RoomContents.Where(r => r.Name == sku.Name).FirstOrDefault(); if (objRoomContent != null) { objRoom.Summary = objRoomContent.Summary; objRoom.ImageUrl = SiteBaseUrl + objRoomContent.ImageUrl; } objProperty.Rooms.Add(objRoom); } objHotelSearchResponse.properties.Add(objProperty); break; } break; } } } catch (Exception ex) { } return(objHotelSearchResponse); }
public List <HotelDescriptiveInfo> HotelSearch(HotelSearchRequest objHSRQ) { _database = MongoDBHandler.mDatabase(); var collection = _database.GetCollection <BsonDocument>("HotelDefinitions"); FilterDefinition <BsonDocument> filter; filter = Builders <BsonDocument> .Filter.Empty; //Hotel Name filter if (objHSRQ.HotelName != null) { filter = filter & Builders <BsonDocument> .Filter.Regex("HotelName", new BsonRegularExpression(new Regex(objHSRQ.HotelName, RegexOptions.IgnoreCase))); } //City Name Filter if (objHSRQ.CityName != null) { filter = filter & Builders <BsonDocument> .Filter.Eq("CityName", objHSRQ.CityName); } //Country Name filter if (objHSRQ.CountryName != null) { filter = filter & Builders <BsonDocument> .Filter.Eq("CountryName", objHSRQ.CountryName); } var searchResult = collection.Find(filter).ToList(); List <HotelDescriptiveInfo> result = new List <HotelDescriptiveInfo>(); foreach (var docs in searchResult) { HotelDescriptiveInfo subResult = new HotelDescriptiveInfo(); subResult.Id = docs["_id"].AsObjectId; subResult.HotelCode = docs["HotelCode"].AsString; subResult.HotelName = docs["HotelName"].AsString; subResult.Rating = docs["Rating"].AsString; subResult.URLs = docs["URLs"].AsString; subResult.AddressLine = docs["AddressLine"].AsString; subResult.PostalCode = docs["PostalCode"].AsString; subResult.CityName = docs["CityName"].AsString; subResult.CountryName = docs["CountryName"].AsString; var position = docs["Position"].AsBsonArray.Select(p => p.AsString).ToArray(); string[] actualPosition = new string[position.Length]; int i = 0; foreach (string pos in position) { actualPosition[i] = pos; i++; } subResult.Position = actualPosition; subResult.PhoneNumber = docs["PhoneNumber"].AsString; result.Add(subResult); } collection = null; _database = null; return(result); }
/// <summary> /// 酒店查询 /// </summary> /// <param name="request"></param> public static BasePageResponse <HotelSearchResponse> GetList(HotelSearchRequest request) { var response = new BasePageResponse <HotelSearchResponse>(); var sql = new StringBuilder(); var sqlTotal = new StringBuilder(); var sqlWhere = new StringBuilder(); var para = new DynamicParameters(); var idList = new List <int>(); //酒店Id var hrsList = new List <H_HotelRoomRuleModel>(); //价格政策查的供应商 var hotelList = new List <H_HotelInfoModel>(); //酒店列表 if (request.SourceId > 0 || !string.IsNullOrEmpty(request.SupplierName)) {//需要查政策 hrsList = GetSupplier(request.SourceId, request.SupplierName, null); idList = hrsList?.Select(x => x.HIId)?.ToList(); } #region Where条件 if (idList != null && idList.Count > 0) { sqlWhere.Append($" AND Id IN ({string.Join(",", idList)} ) "); } if (request.Id > 0) { sqlWhere.Append(" AND Id = @Id "); para.Add("@Id", request.Id); } //if (request.SourceId > 0) //{ // sqlWhere.Append(" AND SSourceId = @SourceId "); // para.Add("@SourceId", request.SourceId); //} //if (!string.IsNullOrEmpty(request.LinkerName)) //{ // sqlWhere.Append(" AND SLinker Like @LinkerName "); // para.Add("@LinkerName", $"%{request.LinkerName}%"); //} if (request.IsValid > 0) { sqlWhere.Append(" AND SIsValid = @IsValid "); para.Add("@IsValid", request.IsValid == 1 ? 1 : 0); } if (request.ProvId > 0) { sqlWhere.Append(" AND HIProvinceId = @ProvId "); para.Add("@ProvId", request.ProvId); } if (request.CityId > 0) { sqlWhere.Append(" AND HICityId = @CityId "); para.Add("@CityId", request.CityId); } if (!string.IsNullOrEmpty(request.Name)) { sqlWhere.Append(" AND HIName Like @Name "); para.Add("@Name", $"%{request.Name}%"); } #endregion sqlTotal.Append(" SELECT Count(1) FROM h_hotelinfo WHERE 1=1 "); sqlTotal.Append(sqlWhere); var total = MysqlHelper.GetScalar <int>(sqlTotal.ToString(), para); response.IsSuccess = 1; if (total > 0) { sql.Append(" SELECT * FROM h_hotelinfo WHERE 1=1 "); sql.Append(sqlWhere); sql.Append(" ORDER BY ID DESC "); sql.Append(MysqlHelper.GetPageSql(request.PageIndex, request.PageSize)); response.Total = total; hotelList = MysqlHelper.GetList <H_HotelInfoModel>(sql.ToString(), para); //重新查资源 hrsList = GetSupplier(0, string.Empty, hotelList.Select(x => x.Id).ToList()); response.List = new List <HotelSearchResponse>(); hotelList?.ForEach(x => { var price = hrsList.Where(s => s.HIId == x.Id)?.ToList(); var source = string.Empty; var supplierName = string.Empty; if (price != null && price.Count > 0) { source = string.Join(",", price.Select(s => s.HRRSourceName).Distinct()); supplierName = string.Join(",", price.Select(s => s.HRRSupplierName).Distinct()); } response.List.Add(new HotelSearchResponse { Id = x.Id, Name = x.HIName, //SourceId = x.SSourceId, CityId = x.HICityId, CityName = x.HICity, ProvName = x.HIProvince, ProvId = x.HIProvinceId, Valid = x.HIIsValid, Source = source ?? string.Empty, SupplierName = supplierName ?? string.Empty, }); }); } return(response); }
/// <summary> /// 酒店查询 /// </summary> /// <param name="request"></param> public static BasePageResponse <HotelSearchResponse> GetList(HotelSearchRequest request) { var response = H_HotelInfoAccess.GetList(request); return(response); }
private async Task ResumeAfterHotelsFormDialog(IDialogContext context, IAwaitable <HotelSearchQuery> result) { try { var searchQuery = await result; DateTime checkin, checkout; var hotelRequest = new HotelSearchRequest(); hotelRequest.Market = searchQuery.Market; hotelRequest.Property = searchQuery.Property; hotelRequest.RoomCount = searchQuery.RoomCount; DateTime.TryParse(searchQuery.CheckinDate, out checkin); DateTime.TryParse(searchQuery.CheckoutDate, out checkout); hotelRequest.CheckinDate = checkin; hotelRequest.CheckoutDate = checkout; var response = _iIAPSearchService.GetHotels(hotelRequest); if (response == null || response.properties == null || response.properties.Count == 0) { await context.PostAsync($"No matching options. Please search with a different criteria"); } else { var resultMessage = context.MakeMessage(); resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel; resultMessage.Attachments = new List <Attachment>(); var property = response.properties.FirstOrDefault(); var rooms = property.Rooms.Where(r => r.ImageUrl != null && r.Summary != null).Take(10); if (hotelRequest.Market != null) { await context.PostAsync($"I found below options in {property.Name}"); } else { await context.PostAsync($"I found below options:"); } foreach (var room in rooms) { HeroCard heroCard = new HeroCard() { Title = room.Name, Subtitle = $"AVG PER NIGHT:{room.AvgRate}", Text = room.Summary, Images = new List <CardImage>() { new CardImage() { Url = room.ImageUrl } }, Buttons = new List <CardAction>() { new CardAction() { Title = "Book Room", Type = ActionTypes.OpenUrl, Value = $"https://www.totalrewards.com/" } } }; resultMessage.Attachments.Add(heroCard.ToAttachment()); } await context.PostAsync(resultMessage); } } catch (FormCanceledException ex) { string reply; if (ex.InnerException == null) { reply = "You have canceled the operation."; } else { reply = $"Oops! Something went wrong :( Technical Details: {ex.InnerException.Message}"; } await context.PostAsync(reply); } finally { context.Done <object>(null); } }