public HotelViewModel()
 {
     MyNewHotel = new Hotel();
     SelectedHotel = new Hotel();
     hotelHandler = new HotelHandler(this);
     createHotelCommand = new RelayCommand(hotelHandler.CreateHotel);
     HotelsList = new HotelCatalog().Hotels;
 }
Exemplo n.º 2
0
 public void CreateHotel(Hotel hotel)
 {
     //Create a Http post
     using (var client = new HttpClient())
     {
         client.BaseAddress = new Uri(serverUrl);
         client.DefaultRequestHeaders.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         string posturl = "api/hotels";
         var response = client.PostAsync(posturl, hotel.GetContentString()).Result;
         if (response.IsSuccessStatusCode)
         {
             new MessageDialog("OK").ShowAsync();
         }
         else
         {
             new MessageDialog("Not OK !" +response.StatusCode.ToString() ).ShowAsync();
         }
     }
 }
Exemplo n.º 3
0
        public static Hotel DeserializeJson(string json)
        {
            Hotel item = JsonConvert.DeserializeObject <Hotel>(json);

            return(item);
        }