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);
        }
Exemple #2
0
        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;
            }
        }