public FrmHotel(HotelObject hotel)
 {
     InitializeComponent();
     Task.Run(() =>
     {
         Thread.Sleep(1000);
         SetHotelInfo(hotel);
     });
     this.hotel = hotel;
     Text       = hotel.hotelName;
 }
 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);
 }
        // 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));
            }
        }
        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}");
                    }
                }
            }));
        }