示例#1
0
        public SearchReq PreparesSearchObj()
        {
            try
            {
                SearchReq searchInputData = new SearchReq();
                searchInputData.CheckInDate      = Convert.ToDateTime(searchData.DateFrom);
                searchInputData.CheckOutDate     = Convert.ToDateTime(searchData.DateTo);
                searchInputData.RoomGuests       = new List <RoomGuest>();
                searchInputData.GuestNationality = searchData.Nat;
                searchInputData.HotelCodeList    = HotelIds;
                searchInputData.NoOfRooms        = searchData.SearchRooms.Count;
                searchInputData.CityId           = int.Parse(searchData.CityName);
                foreach (var item in searchData.SearchRooms)
                {
                    RoomGuest guest = new RoomGuest
                    {
                        AdultCount = item.Adult,
                        ChildAge   = item.Child.ToArray(),
                        ChildCount = item.Child.Count
                    };

                    searchInputData.RoomGuests.Add(guest);
                }


                return(searchInputData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#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;
            }
        }