Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HotelSearch hs = (HotelSearch)Session[new HotelSearch().SessionKey];
            if (hs != null)
            {
                this.tocityName.Value   = hs.CityName;
                this.txt_fromDate.Value = hs.FromDate.ToString("yyyy-MM-dd");
                this.txt_toDate.Value   = hs.ToDate.ToString("yyyy-MM-dd");
            }
            else
            {
                this.tocityName.Value   = "纽约";
                this.txt_fromDate.Value = (DateTime.Now.AddDays(5)).ToString("yyyy-MM-dd");
                this.txt_toDate.Value   = (DateTime.Now.AddDays(6)).ToString("yyyy-MM-dd");
            }
        }

        //特推酒店
        recomhotel = getRomHotellist(13, 0, 1, 1);
        istophotel = getRomHotellist(24, 1, 0, 0);

        focuNews       = getNewsByType(7, 0, 0, 5);
        hotelList      = getHotelList("曼谷", 8);
        travelNewsList = getTravelNews(9);
        clickOrder     = getQuanByType(0, 1, 9, " order by addtime asc ");

        server1 = getServer(1);
        server2 = getServer(2);
        server3 = getServer(3);
    }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private static AccommodationSearchResponse SendSearchRequest(TripAdvisorRequest request)
        {
            var myUri = new Uri(request.Hotels[0].partner_url);

            var superIds = new List <string>();

            foreach (var hotel in request.Hotels)
            {
                superIds.Add(hotel.partner_id);
            }

            var aggResponce = HotelSearch.Search(new AccommodationSearchRequest
            {
                Authentication = new Authentication
                {
                    UserName = "******",
                    Password = "******"
                },
                CheckIn         = request.StartDate,
                CheckOut        = request.EndDate,
                ChildAge        = new List <int>(),
                CityCode        = long.Parse(HttpUtility.ParseQueryString(myUri.Query).Get("city")),
                CountryCode     = long.Parse(HttpUtility.ParseQueryString(myUri.Query).Get("country")),
                MinStarRating   = null,
                NumberOfAdults  = request.Adults,
                NumberOfInfants = null,
                NumberOfRooms   = request.Rooms,
                ResortCode      = null,
                SuperIds        = superIds
            }, InitializeService.Settings);

            return(aggResponce);
        }
Exemplo n.º 3
0
        public PagedResponse <HotelDto> Execute(HotelSearch search)
        {
            var hotelsQuery = this.dbContext.Hotels
                              .Include(h => h.Location)
                              .AsQueryable();

            if (search.Address != null)
            {
                hotelsQuery = hotelsQuery.Where(h => h.Location.Address.ToLower().Contains(search.Address.ToLower()));
            }

            if (search.City != null)
            {
                hotelsQuery = hotelsQuery.Where(h => h.Location.City.ToLower().Contains(search.City.ToLower()));
            }

            if (search.Country != null)
            {
                hotelsQuery = hotelsQuery.Where(h => h.Location.Country.ToLower().Contains(search.Country.ToLower()));
            }

            if (search.PostalCode > 0)
            {
                hotelsQuery = hotelsQuery.Where(h => h.Location.PostalCode == search.PostalCode);
            }

            if (search.Name != null)
            {
                hotelsQuery = hotelsQuery.Where(h => h.Name.ToLower().Contains(search.Name.ToLower()));
            }

            var hotels = this.mapper.Map <List <HotelDto> >(hotelsQuery.FormatForPagedResponse(search));

            return(hotels.GeneratePagedResponse(search, hotelsQuery));
        }
Exemplo n.º 4
0
        public static IList <HotelOffer> GetOffers(HotelSearch hotelSearch)
        {
            string requestUri = uri;

            if (!string.IsNullOrEmpty(hotelSearch.Destination))
            {
                requestUri += "&destinationName=" + HttpUtility.UrlEncode(hotelSearch.Destination);
            }
            if (!string.IsNullOrEmpty(hotelSearch.TripStartDateFrom))
            {
                requestUri += "&minTripStartDate=" + HttpUtility.UrlEncode(hotelSearch.TripStartDateFrom);
            }
            if (!string.IsNullOrEmpty(hotelSearch.TripStartDateTo))
            {
                requestUri += "&maxTripStartDate=" + HttpUtility.UrlEncode(hotelSearch.TripStartDateTo);
            }
            if (!string.IsNullOrEmpty(hotelSearch.StayLength))
            {
                requestUri += "&lengthOfStay=" + HttpUtility.UrlEncode(hotelSearch.StayLength);
            }
            if (!string.IsNullOrEmpty(hotelSearch.StarRatingFrom))
            {
                requestUri += "&minStarRating=" + HttpUtility.UrlEncode(hotelSearch.StarRatingFrom);
            }

            byte[]          responseBytes   = RequestWebService(requestUri);
            ServiceResponse serviceResponse = JsonDeserialize <ServiceResponse>(responseBytes);

            return(serviceResponse.offers.Hotel);
        }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {

        NameValueCollection coll = Request.QueryString;
        CityName = coll["cityName"];
        if (CityName == null)
        {    
            Response.Redirect("Hotel.aspx");
            return;
        }
        hs= (HotelSearch)Session[new HotelSearch().SessionKey];
        if (hs == null || hs.CityName != CityName)
        {
            hs = new HotelSearch();
            hs.CityName = CityName;
            hs.HotelName = string.Empty;
            hs.FromDate = DateTime.Now.AddDays(5);
            hs.ToDate = DateTime.Now.AddDays(6);
            hs.MinPrice = 0;
            hs.MaxPrice = 0;
            hs.BookNum = 1;
            Session[hs.SessionKey] = hs;
        }
        
        if (!IsPostBack)
        {
            this.tocityName.Value = hs.CityName;
            this.txt_hotelName.Value = hs.HotelName;
            this.txt_fromDate.Value = hs.FromDate.ToString("yyyy-MM-dd");
            this.txt_toDate.Value = hs.ToDate.ToString("yyyy-MM-dd");
            if (hs.MinPrice != 0 || hs.MaxPrice != 0)
            {
                this.txt_minPrice.Value = hs.MinPrice.ToString();
                this.txt_maxPrice.Value = hs.MaxPrice.ToString();
            }
            this.selBookNum.Value = hs.BookNum.ToString();
        }
        this.Page.Title = hs.CityName+"酒店-特价酒店-飞瀛网";

        City = getCityInfo(hs.CityName.Trim());
        if (City == null)
        {
            scripthelp.AlertAndRedirect("无法找到该目的地城市!", "Hotel.aspx", this.Page);
            return;
        }
        else
            stateName = City["stateName"].ToString();


        GetShopNewslist(hs.CityName, hs.HotelName, hs.FromDate.ToShortDateString(), hs.ToDate.ToShortDateString(), hs.MinPrice, hs.MaxPrice, hs.BookNum);

        getHotelListByCity(hs.CityName, hs.HotelName, hs.FromDate.ToShortDateString(), hs.ToDate.ToShortDateString(), hs.MinPrice, hs.MaxPrice, hs.BookNum);

        getRecommendTicket(0, Convert.ToInt32(City["sId"]), 10);
        
    }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the hotel list.
        /// </summary>
        /// <returns>List of ApiHotelInfo - all hotel info.</returns>
        /// <param name="searchCriteria">Search criteria.</param>
        /// <param name="search">Search.</param>
        public List <ApiHotelInfo> GetHotelList(HotelSearch searchCriteria, ISearchCriteria search)
        {
            // Get Search query string from Search Criteria Object
            var queryString = search.GetSearchQuery(searchCriteria);

            //call expedia api passing search criteria query string
            var hotelApiList = makeRequest(queryString);

            return(hotelApiList.ToList());
        }
Exemplo n.º 7
0
        //
        // GET: /Home/

        public ActionResult Index(HotelSearch hotelSearch)
        {
            if (Request.HttpMethod == "GET")    // page requested
            {
                return(View((IList <HotelOffer>)null));
            }
            ViewBag.HotelSearch = hotelSearch;
            IList <HotelOffer> hotelOffers = HotelService.GetOffers(hotelSearch);

            if (hotelOffers == null)
            {
                return(View(new List <HotelOffer>()));
            }
            return(View(hotelOffers));
        }
        // GET api/<controller>
        public HotelSearch  Get(string searchid, string city, string checkind, string checkoutd, string guestscount, string selroom, string selaudults, string selchilds)
        {
            HACondition Hac = GetSearchConditon(city, checkind, checkoutd, guestscount, Convert.ToInt32(selroom), Convert.ToInt32(selaudults), Convert.ToInt32(selchilds));
            HotelSearch hs  = new HotelSearch(Hac, searchid);
            //string filePathRQ = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelAvail/" + searchid + "_Context.xml");
            //File.WriteAllText(filePathRQ, hs.ContextResult);
            //string filePathHA = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelAvail/" + searchid + "_HotelAvail.xml");
            //File.WriteAllText(filePathHA, hs.XMLResult);
            DataTable dtHList = hs.dtBPIadd;
            DataSet   ds      = new DataSet();

            ds.Tables.Add(dtHList);
            string HLFPath = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelAvail/" + searchid + "_HotelList.xml");

            ds.WriteXml(HLFPath);
            return(hs);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the search query.
        /// </summary>
        /// <returns>The search query string.</returns>
        /// <param name="searchCriteria">Search criteria.</param>
        public string GetSearchQuery(HotelSearch searchCriteria)
        {
            if (searchCriteria != null)
            {
                // Get all properties on the object
                var properties = searchCriteria.GetType().GetProperties()
                                 .Where(x => x.CanRead)
                                 .Where(x => x.GetValue(searchCriteria, null) != null)
                                 .ToDictionary(x => x.Name, x => x.GetValue(searchCriteria, null));

                // reurn query string
                return(HttpContext.Current.Server.UrlDecode(string.Join("&", properties
                                                                        .Select(x => string.Concat(
                                                                                    Uri.EscapeDataString(x.Key), "=",
                                                                                    Uri.EscapeDataString(x.Value.ToString()))))));
            }
            return(string.Empty);
        }
Exemplo n.º 10
0
        public static IEnumerable <DomainHotel> ToDomainHotel(HotelSearch hotelSearch)
        {
            var hotelsList = new List <DomainHotel>();

            foreach (var h in hotelSearch.Suggestions)
            {
                var hotels = h.Entities.Where(e => e.Type == "HOTEL");
                hotelsList.AddRange(hotels.Select(e => new DomainHotel
                {
                    GeoId                     = e.GeoId,
                    DestinationId             = e.DestinationId,
                    LandmarkCityDestinationId = e.LandmarkCityDestinationId,
                    Type         = e.Type,
                    Caption      = e.Caption,
                    RedirectPage = e.RedirectPage,
                    Latitude     = e.Latitude,
                    Longitude    = e.Longitude,
                    Name         = e.Name,
                    HotelId      = e.Latitude + e.Longitude + e.Name
                }));
            }
            return(hotelsList);
        }
Exemplo n.º 11
0
        public void FillHotelSearchFields(HotelSearch hotelSearch)
        {
            CitySearch.SendKeys(hotelSearch.City);
            _browserSession.FindXPath($"//*[text()='Locations']/following-sibling::ul/li//span[text()='{hotelSearch.City}']").Click();

            CheckIn.FillInWith(hotelSearch.CheckIn);
            CheckOut.FillInWith(hotelSearch.CheckOut);

            TravellersInput.Click();

            //fill the adult and child fields by pressing the + or - button
            while (!AdultInput.GetAttribute("value").Equals(hotelSearch.Adults))
            {
                if (int.Parse(AdultInput.GetAttribute("value")) < int.Parse(hotelSearch.Adults))
                {
                    _browserSession.FindId("hadultPlusBtn").Click();
                }
                else
                {
                    _browserSession.FindId("hadultMinusBtn").Click();
                }
            }
            while (!ChildInput.GetAttribute("value").Equals(hotelSearch.Childs))
            {
                if (int.Parse(ChildInput.GetAttribute("value")) < int.Parse(hotelSearch.Childs))
                {
                    _browserSession.FindId("hchildPlusBtn").Click();
                }
                else
                {
                    _browserSession.FindId("hchildMinusBtn").Click();
                }
            }

            TravellersInput.Click(); //to save the changes to the adult and child fields
        }
Exemplo n.º 12
0
 public Task <SingleHotelOffersResponse> GetSingleHotelOffersAsync(SingleHotelOfferRequest request)
 {
     return(HotelSearch.GetSingleHotelOffersAsync(request.HotelId, request.CheckInDate, request.CheckOutDate, request.Adults, request.ChildAges, request.RateCodes, request.RoomQuantity, request.Currency, request.PaymentPolicy, request.BoardType, request.View, request.Lang, System.Threading.CancellationToken.None));
 }
Exemplo n.º 13
0
        public void WhenIFillTheHotelSearchWithTheFollowingData(Table table)
        {
            HotelSearch hotelSearch = table.CreateInstance <HotelSearch>();

            Pages.HomePage.FillHotelSearchFields(hotelSearch);
        }
Exemplo n.º 14
0
 public IActionResult Get([FromQuery] HotelSearch hotelSearch, [FromServices] IGetHotelsQuery getHotels)
 {
     return(Ok(_dispatcher.DispatchQuery(getHotels, hotelSearch)));
 }
Exemplo n.º 15
0
        public ActionResult SubmitSearch(PackageIndexVM packageData)
        {
            DataLayer dl = new DataLayer();

            packageData.desCode = (from u in dl.locations
                                   where  u.city.ToLower() == packageData.desCity.ToLower()
                                   select u.code).ToList <string>().FirstOrDefault();

            // HOTELS:
            HotelSearch hs = new HotelSearch();

            hs.FillData(packageData.desCode, packageData.sdate, packageData.edate);
            hs.BuildURL();
            string json = hs.GetJson();

            dynamic         results = JsonConvert.DeserializeObject(json); // convert incoming data to json form
            SearchResultsVM sr      = new SearchResultsVM();

            sr.hotelSearchResultsVM = new List <HotelSearchResultsVM>();
            sr.startdDate           = packageData.sdate;
            sr.endDate = packageData.edate;
            sr.nights  = ToolsClass.getNumOfNights(ToolsClass.getDate(sr.startdDate), ToolsClass.getDate(sr.endDate));

            for (int i = 0; i < results.results.Count; ++i)
            {
                ImageSearch image = new ImageSearch();

                try
                {
                    image.SetHotelName(results.results[i].property_name.ToString()); // initialize object by GoogleAPI
                }
                catch (Exception)
                {
                    Thread.Sleep(1000);
                    return(SubmitSearch(packageData));
                }

                int newRating = -1; // initialize to -1
                try
                {
                    if (results.results[i].awards[0].rating != null)
                    {
                        newRating = results.results[i].awards[0].rating;
                    }
                }
                catch (Exception) { }
                if (newRating == -1)
                {
                    newRating = GenerateRating();
                }

                HotelSearchResultsVM temp = new HotelSearchResultsVM()
                {
                    originalLink     = hs.GetSearchURL(), // to fix the api room problem
                    hotelLink        = results.results[i]._links.more_rooms_at_this_hotel.href,
                    hotelName        = results.results[i].property_name,
                    hotelDescription = results.results[i].marketing_text,
                    rating           = newRating,
                    hotelPrice       = results.results[i].total_price.amount,
                    hotelImage       = image.GetImage() // image is an object
                };
                sr.hotelSearchResultsVM.Add(temp);
            }

            // FLIGHTS:
            FlightSearch flightSearch = new FlightSearch();

            flightSearch.FillData("TLV", packageData.desCode, packageData.sdate, packageData.edate, "Israel", "Tel Aviv", packageData.desCountry, packageData.desCity);

            // if no results were found (400: bad request)
            if (flightSearch.GetResponse() != "")
            {
                List <PackageDetails> packages = new List <PackageDetails>();
                packages.Add(new PackageDetails()
                {
                    flight = new FlightInfoVM()
                    {
                        departureDate      = packageData.sdate,
                        returnDate         = packageData.edate,
                        destinationCity    = packageData.desCity,
                        destinationCountry = packageData.desCountry,
                        originCity         = "Tel Aviv",
                        originCountry      = "Israel",
                    }
                });

                PackageDetailsVM newObj = new PackageDetailsVM()
                {
                    composition = packageData.composition,
                    packages    = packages,
                };
                return(View("SearchResults", newObj));
            }

            // for the google map
            string[] loc       = flightSearch.GetLocation().Split(',');
            double   latitude  = Double.Parse(loc[0]);
            double   longitude = Double.Parse(loc[1]);

            // create object to pass to the view
            FlightSearchResultsVM flightSearchResultsVM = new FlightSearchResultsVM()
            {
                departureDate       = flightSearch.GetDepartureDate(),
                destinationCity     = flightSearch.GetDestinationCity(),
                destinationCodeCity = flightSearch.GetDestinationCodeCity(),
                destinationCountry  = flightSearch.GetDestinationCountry(),
                inbound             = flightSearch.GetInbound(),
                originCity          = flightSearch.GetOriginCity(),
                originCodeCity      = flightSearch.GetOriginCodeCity(),
                originCountry       = flightSearch.GetOriginCountry(),
                outbound            = flightSearch.GetOutbound(),
                price          = flightSearch.GetPrice(),
                returnDate     = flightSearch.GetReturnDate(),
                seatsRemaining = flightSearch.GetSeatsRemaining(),
                airline        = flightSearch.GetAirline(),
            };

            PackageDetailsVM pdvm = new PackageDetailsVM();

            pdvm.composition = packageData.composition;
            var rand = new Random();

            foreach (HotelSearchResultsVM h in sr.hotelSearchResultsVM)
            {
                PackageDetails pd = new PackageDetails();
                pd.hotel = h;

                int          n = rand.Next(flightSearchResultsVM.airline.Count());
                FlightInfoVM f = new FlightInfoVM()
                {
                    airline             = flightSearchResultsVM.airline[n],
                    inbound             = flightSearchResultsVM.inbound[n],
                    outbound            = flightSearchResultsVM.outbound[n],
                    departureDate       = flightSearchResultsVM.departureDate,
                    returnDate          = flightSearchResultsVM.returnDate,
                    originCountry       = flightSearchResultsVM.originCountry,
                    originCity          = flightSearchResultsVM.originCity,
                    destinationCountry  = flightSearchResultsVM.destinationCountry,
                    destinationCity     = flightSearchResultsVM.destinationCity,
                    originCodeCity      = flightSearchResultsVM.originCodeCity,
                    destinationCodeCity = flightSearchResultsVM.destinationCodeCity,
                    seatsRemaining      = flightSearchResultsVM.seatsRemaining[n],
                    price = flightSearchResultsVM.price[n].ToString()
                };
                pd.flight = f;

                pd.price = (pd.hotel.hotelPrice + Convert.ToDouble(pd.flight.price)) * Tools.ToolsClass.getPricePercent(pdvm.composition);

                pdvm.packages.Add(pd);
            }

            pdvm.nights = sr.nights;

            pdvm.latitude  = latitude;
            pdvm.longitude = longitude;

            return(View("SearchResults", pdvm));
        }
Exemplo n.º 16
0
        //                                               Index page for hotels (include search)
        //-----------------------------------------------------------------------------------------------------------------------------
        public ActionResult Index()
        {
            HotelIndexVM hivm = new HotelIndexVM();
            DataLayer    dl   = new DataLayer();

            List <string> codes = (from u in dl.locations select u.code).ToList <string>();
            var           rand  = new Random();

            while (hivm.hotels.Count < 6)
            {
                string      code = codes.ElementAt(rand.Next(codes.Count()));
                HotelSearch hs   = new HotelSearch();

                hs.FillData(code, "15.07.2018", "18.07.2018");
                hs.BuildURL();
                string json = hs.GetJson();

                dynamic results = JsonConvert.DeserializeObject(json); // convert incoming data to json form
                if (results.results.Count > 0)
                {
                    ImageSearch image = new ImageSearch();

                    try
                    {
                        image.SetHotelName(results.results[0].property_name.ToString()); // initialize object by GoogleAPI
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(1000);
                        return(Index());
                    }

                    int newRating = -1; // initialize to -1
                    try
                    {
                        newRating = results.results[0].awards[0].rating;
                    }
                    catch (Exception) { newRating = GenerateRating(); }
                    if (newRating == -1)
                    {
                        newRating = GenerateRating();
                    }

                    HotelSearchResultsVM temp = new HotelSearchResultsVM()
                    {
                        hotelLink        = results.results[0]._links.more_rooms_at_this_hotel.href,
                        hotelName        = results.results[0].property_name,
                        hotelDescription = results.results[0].marketing_text,
                        rating           = newRating,
                        hotelPrice       = results.results[0].total_price.amount,
                        hotelImage       = image.GetImage() // image is an object
                    };
                    hivm.hotels.Add(temp);
                }
            }
            hivm.countries = (from u in dl.locations
                              select u.country).ToList <string>().GroupBy(p => p)
                             .Select(g => g.First()).OrderBy(q => q)
                             .ToList();

            hivm.cities = (from u in dl.locations
                           where u.country == hivm.countries.FirstOrDefault()
                           select u.city).ToList <string>().GroupBy(p => p)
                          .Select(g => g.First()).OrderBy(q => q)
                          .ToList();
            return(View(hivm));
        }
Exemplo n.º 17
0
        public ActionResult SubmitSearch(HotelIndexVM hotelsData)
        {
            DataLayer dl = new DataLayer();

            hotelsData.code = (from u in dl.locations
                               where u.city.ToLower() == hotelsData.city.ToLower()
                               select u.code).ToList <string>().FirstOrDefault();

            HotelSearch hs = new HotelSearch();

            hs.FillData(hotelsData.code, hotelsData.sdate, hotelsData.edate);
            hs.BuildURL();
            string json = hs.GetJson();

            dynamic         results = JsonConvert.DeserializeObject(json); // convert incoming data to json form
            SearchResultsVM sr      = new SearchResultsVM();

            sr.hotelSearchResultsVM = new List <HotelSearchResultsVM>();
            sr.startdDate           = hotelsData.sdate;
            sr.endDate      = hotelsData.edate;
            sr.originalLink = hs.GetSearchURL(); // to fix the api room problem
            sr.destination  = hotelsData.city + ", " + hotelsData.country;

            if (results.results.Count != 0)
            { // for the google map
                string   realCode = hs.GetLocation(hotelsData.code, "firstStage");
                string[] loc      = hs.GetLocation(realCode, "secondStage").Split(',');
                sr.latitude  = Double.Parse(loc[0]);
                sr.longitude = Double.Parse(loc[1]);
            }

            sr.nights = ToolsClass.getNumOfNights(ToolsClass.getDate(sr.startdDate), ToolsClass.getDate(sr.endDate));

            for (int i = 0; i < results.results.Count; ++i)
            {
                ImageSearch image = new ImageSearch();

                try
                {
                    image.SetHotelName(results.results[i].property_name.ToString()); // initialize object by GoogleAPI
                }
                catch (Exception)
                {
                    Thread.Sleep(1000);
                    return(SubmitSearch(hotelsData));
                }

                int newRating = -1; // initialize to -1
                try
                {
                    if (results.results[i].awards[0].rating != null)
                    {
                        newRating = results.results[i].awards[0].rating;
                    }
                }
                catch (Exception) { }
                if (newRating == -1)
                {
                    newRating = GenerateRating();
                }

                HotelSearchResultsVM temp = new HotelSearchResultsVM()
                {
                    hotelLink        = results.results[i]._links.more_rooms_at_this_hotel.href,
                    hotelName        = results.results[i].property_name,
                    hotelDescription = results.results[i].marketing_text,
                    rating           = newRating,
                    hotelPrice       = results.results[i].total_price.amount,
                    hotelImage       = image.GetImage() // image is an object
                };
                sr.hotelSearchResultsVM.Add(temp);
            }
            return(View("SearchResults", sr));
        }
 public AccommodationSearchResponse AccommodationSearch(AccommodationSearchRequest request)
 {
     return(HotelSearch.Search(request, InitializeService.Settings));
 }
Exemplo n.º 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["hid"] == null)
        {
            Response.Redirect("Hotel.aspx");
            return;
        }

        id       = Convert.ToInt32(Request.QueryString["hid"]);
        hotelOne = GetHotelDetail(id);

        DataTable dt = new DataTable();

        dt.Columns.Add("Pic");
        dt.Columns.Add("Name");

        if (!string.IsNullOrEmpty(hotelOne["pic2"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic2"].ToString(), hotelOne["HotelName"]);
        }
        if (!string.IsNullOrEmpty(hotelOne["pic3"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic3"].ToString(), hotelOne["HotelName"]);
        }
        if (!string.IsNullOrEmpty(hotelOne["pic4"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic4"].ToString(), hotelOne["HotelName"]);
        }
        if (!string.IsNullOrEmpty(hotelOne["pic5"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic5"].ToString(), hotelOne["HotelName"]);
        }
        if (!string.IsNullOrEmpty(hotelOne["pic6"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic6"].ToString(), hotelOne["HotelName"]);
        }
        if (!string.IsNullOrEmpty(hotelOne["pic7"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic7"].ToString(), hotelOne["HotelName"]);
        }
        if (!string.IsNullOrEmpty(hotelOne["pic8"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic8"].ToString(), hotelOne["HotelName"]);
        }
        if (!string.IsNullOrEmpty(hotelOne["pic9"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic9"].ToString(), hotelOne["HotelName"]);
        }
        if (!string.IsNullOrEmpty(hotelOne["pic10"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic10"].ToString(), hotelOne["HotelName"]);
        }
        if (!string.IsNullOrEmpty(hotelOne["pic11"].ToString()))
        {
            dt.Rows.Add(hotelOne["pic11"].ToString(), hotelOne["HotelName"]);
        }
        this.repHotelPic.DataSource = dt;
        this.repHotelPic.DataBind();


        ReReadHotel(hotelOne);

        getHotelListByCity(Convert.ToInt32(hotelOne["cityId"]));

        getRecommendTicket(0, Convert.ToInt32(hotelOne["sId"]), 10);

        bindComment(id);

        string str = "update FY_Hotel set hots=hots+1 where hId=" + id;

        SqlHelper.ExecuteNonQuery(SqlHelper.ConnString_insert, CommandType.Text, str);

        //读取cookie
        HttpCookie hc = Request.Cookies["HotelRandom" + id];

        if (hc != null)
        {
            RanNum = int.Parse(hc.Values["Num"]);
        }
        else
        {
            //记录cookie
            RanNum = new Random().Next(25, 300);
            HttpCookie hci = new HttpCookie("HotelRandom" + id);
            hci.Values["Num"] = RanNum.ToString();
            hci.Expires       = DateTime.Now.AddDays(3);
            Response.Cookies.Add(hci);
        }

        if (hotelOne == null)
        {
            scripthelp.AlertAndRedirect("无法找到该酒店!", "Hotel.aspx", this.Page);
            return;
        }

        hs = (HotelSearch)Session[new HotelSearch().SessionKey];
        if (hs == null || hs.CityName != hotelOne["chName"].ToString())
        {
            hs                     = new HotelSearch();
            hs.CityName            = hotelOne["chName"].ToString();
            hs.HotelName           = string.Empty;
            hs.FromDate            = DateTime.Now.AddDays(5);
            hs.ToDate              = DateTime.Now.AddDays(6);
            hs.MinPrice            = 0;
            hs.MaxPrice            = 0;
            hs.BookNum             = 1;
            Session[hs.SessionKey] = hs;
        }

        if (!IsPostBack)
        {
            this.tocityName.Value    = hs.CityName;
            this.txt_hotelName.Value = hs.HotelName;
            this.txt_fromDate.Value  = hs.FromDate.ToString("yyyy-MM-dd");
            this.txt_toDate.Value    = hs.ToDate.ToString("yyyy-MM-dd");
            if (hs.MinPrice != 0 || hs.MaxPrice != 0)
            {
                this.txt_minPrice.Value = hs.MinPrice.ToString();
                this.txt_maxPrice.Value = hs.MaxPrice.ToString();
            }
            this.selBookNum.Value       = hs.BookNum.ToString();
            this.sel_bookroomnum.Value  = hs.BookNum.ToString();
            this.sel_bookpesonnum.Value = "1";
            this.txt_bookfromdate.Value = hs.FromDate.ToString("yyyy-MM-dd");
            this.txt_booktodate.Value   = hs.ToDate.ToString("yyyy-MM-dd");
        }
        this.Page.Title = hotelOne["HotelName"] + "-特价酒店-飞瀛网";


        if (!IsPostBack)
        {
            for (int i = 0; i < 5; i++)
            {
                this.sel_year.Items.Insert(i,
                                           new ListItem((DateTime.Now.Year + i).ToString(), (DateTime.Now.Year + i).ToString())
                                           );
            }

            this.radtype0.Checked = true;
        }
    }
Exemplo n.º 20
0
        public ActionResult GetRandomHotelsByJson(List <string> loc)
        {
            HotelIndexVM hivm = new HotelIndexVM();
            DataLayer    dl   = new DataLayer();

            List <Locations> locations = GetLocations(loc);
            var rand = new Random();

            string startDate = "13.08.2018";
            string endDate   = "20.08.2018";

            hivm.nights = ToolsClass.getNumOfNights(ToolsClass.getDate(startDate), ToolsClass.getDate(endDate));

            while (hivm.hotels.Count < 4)
            {
                int         random = rand.Next(0, locations.Count);
                string      code   = locations[random].code;
                HotelSearch hs     = new HotelSearch();


                hs.FillData(code, startDate, endDate);
                hs.BuildURL();
                string json         = hs.GetJson();
                string originalLink = hs.GetSearchURL();

                dynamic results = JsonConvert.DeserializeObject(json); // convert incoming data to json form
                if (results.results.Count > 0)
                {
                    ImageSearch image = new ImageSearch();

                    try
                    {
                        image.SetHotelName(results.results[0].property_name.ToString()); // initialize object by GoogleAPI
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(1000);
                        return(Index());
                    }

                    int newRating = -1; // initialize to -1
                    try
                    {
                        newRating = results.results[0].awards[0].rating;
                    }
                    catch (Exception) { newRating = GenerateRating(); }
                    if (newRating == -1)
                    {
                        newRating = GenerateRating();
                    }

                    HotelSearchResultsVM temp = new HotelSearchResultsVM()
                    {
                        originalLink     = originalLink,
                        startDate        = startDate,
                        endDate          = endDate,
                        location         = locations[random].city + ", " + locations[random].country,
                        hotelLink        = results.results[0]._links.more_rooms_at_this_hotel.href,
                        hotelName        = results.results[0].property_name,
                        hotelDescription = results.results[0].marketing_text,
                        rating           = newRating,
                        hotelPrice       = results.results[0].total_price.amount,
                        hotelImage       = image.GetImage() // image is an object
                    };
                    hivm.hotels.Add(temp);
                    locations.RemoveAt(random);
                }
            }
            return(Json(hivm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 21
0
 public Task <HotelSearch.MultiHotelOffersResponse> GetMultiHotelOffersAsync(MultiHotelOffersRequest request)
 {
     return(HotelSearch.GetMultiHotelOffersAsync(request.CityCode, request.Latitude, request.Longitude, request.HotelIds, request.CheckInDate, request.CheckOutDate, request.RoomQuantity, request.Adults, request.ChildAges, request.Radius, request.RadiusUnit, request.HotelName, request.Chains, request.RateCodes, request.Amenities, request.Ratings, request.PriceRange, request.Currency, request.PaymentPolicy, request.BoardType, request.IncludeClosed, request.BestRateOnly, request.View, request.Sort, request.Pagelimit, request.PageOffset, request.Lang, System.Threading.CancellationToken.None));
 }
Exemplo n.º 22
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string cityName = this.tocityName.Value;

        if (string.IsNullOrEmpty(cityName))
        {
            scripthelp.Alert("请选择目的地城市!", this.Page);
            return;
        }
        string hotelName = this.txt_hotelName.Value;

        DateTime fromDate;
        DateTime toDate;

        if (string.IsNullOrEmpty(this.txt_fromDate.Value))
        {
            scripthelp.Alert("请选择入住日期!", this.Page);
            return;
        }
        if (!DateTime.TryParse(this.txt_fromDate.Value, out fromDate))
        {
            scripthelp.Alert("请选择正确的入住日期!", this.Page);
            return;
        }
        if (string.IsNullOrEmpty(this.txt_toDate.Value))
        {
            scripthelp.Alert("请选择退房日期!", this.Page);
            return;
        }
        if (!DateTime.TryParse(this.txt_toDate.Value, out toDate))
        {
            scripthelp.Alert("请选择正确的退房日期!", this.Page);
            return;
        }
        if (DateTime.Compare(DateTime.Now, fromDate) > -1)
        {
            scripthelp.Alert("入住日期已过期!", this.Page);
            return;
        }

        if (DateTime.Compare(fromDate, toDate) > -1)
        {
            scripthelp.Alert("入住日期不能小于退房日期!", this.Page);
            return;
        }

        int minPrice = 0;
        int maxPrice = 0;

        if (!string.IsNullOrEmpty(this.txt_minPrice.Value))
        {
            if (!int.TryParse(this.txt_minPrice.Value, out minPrice))
            {
                scripthelp.Alert("价格为正整数格式!", this.Page);
                return;
            }
        }
        if (!string.IsNullOrEmpty(this.txt_maxPrice.Value))
        {
            if (!int.TryParse(this.txt_maxPrice.Value, out maxPrice))
            {
                scripthelp.Alert("价格为正整数格式!", this.Page);
                return;
            }
        }

        if (minPrice > maxPrice)
        {
            scripthelp.Alert("最低价格小于最高价格!", this.Page);
            return;
        }

        int bookNum = int.Parse(this.selBookNum.Value);
        //记录session
        HotelSearch hs = new HotelSearch();

        hs.CityName            = cityName;
        hs.HotelName           = hotelName;
        hs.FromDate            = fromDate;
        hs.ToDate              = toDate;
        hs.MinPrice            = minPrice;
        hs.MaxPrice            = maxPrice;
        hs.BookNum             = bookNum;
        Session[hs.SessionKey] = hs;

        Response.Redirect("hotellist_" + Server.UrlEncode(cityName) + ".htm");
    }
Exemplo n.º 23
0
 public Task <SingleHotelOffersResponse> GetOfferPricingAsync(string offerId, string lang)
 {
     return(HotelSearch.GetOfferPricingAsync(offerId, lang, System.Threading.CancellationToken.None));
 }