コード例 #1
0
 public FrmHotel(HotelObject hotel)
 {
     InitializeComponent();
     Task.Run(() =>
     {
         Thread.Sleep(1000);
         SetHotelInfo(hotel);
     });
     this.hotel = hotel;
     Text       = hotel.hotelName;
 }
コード例 #2
0
 private HotelObject GetJson(string url)
 {
     using (var w = new WebClient())
     {
         w.Headers.Add("X-Signature", GetAuthenticed.Signature());
         w.Headers.Add("secret", "hC4G64FvN9");
         w.Headers.Add("Api-Key", "9g9e3fpc5ea8e692pdznrk52");
         w.Headers.Add("Accept", "application/json");
         HotelObject rootObject = new HotelObject();
         var         json_data  = string.Empty;
         try
         {
             json_data = w.DownloadString(url);
         }
         catch
         {
         }
         return(JsonConvert.DeserializeObject <HotelObject>(json_data));
     }
 }
コード例 #3
0
 public static bool SetComment(string comment, HotelObject hotel)
 {
     if (cookieUID != "")
     {
         DefaultAnswObject auth = JsonConvert.DeserializeObject <DefaultAnswObject>(SendRequest(new Dictionary <string, string>()
         {
             { "hid", hotel.id.ToString() },
             { "comment", comment }
         }, "POST", "setComment"));
         if (auth.successful)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
コード例 #4
0
        // GET: Home
        public ActionResult Index()
        {
            using (WebClient client = new WebClient())
            {
                const string endpoint = "api.test.hotelbeds.com";

                UriBuilder uriBuilder = new UriBuilder();
                uriBuilder.Host = endpoint;
                uriBuilder.Path = "activity-content-api/3.0/hotels/en/PMI";


                uriBuilder.Scheme = "https";
                string       finalpath = uriBuilder.ToString();
                HotelObject  _model    = GetJson(finalpath);
                List <Hotel> model     = _model.hotels;



                return(View("Index", model));
            }
        }
コード例 #5
0
        private void SetHotelInfo(HotelObject hotel)
        {
            this.Invoke(new Action(() =>
            {
                tbHotelName.Text  = hotel.hotelName;
                tbCost.Text       = hotel.cost.ToString();
                tbStars.Text      = hotel.stars.ToString();
                tbCountry.Text    = hotel.country;
                tbCity.Text       = hotel.city;
                rtbInfo.Text      = hotel.info;
                pictureBox1.Image = Image.FromFile(hotel.image);

                pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;

                if ((comments = Network.GetComments(hotel.id)) != null)
                {
                    foreach (CommentObject comment in comments)
                    {
                        lbComments.Items.Add($"{comment.user}: {comment.text}");
                    }
                }
            }));
        }