internal async Task <bool> ChangeStateOfAirCon(AirConDto airConDto) { var url = "https://ondo-sea.azurewebsites.net/api/aircon"; try { var airconJson = JsonConvert.SerializeObject(airConDto); var httpcontent = new StringContent(airconJson.ToString(), Encoding.UTF8, "application/json"); HttpClient client = new HttpClient(); var response = await client.PostAsync(url, httpcontent); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); var Items = JsonConvert.DeserializeObject <ObservableCollection <DeviceDto> >(content); return(true); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(false); }
private async void ChangeState(AirConDto airConDto) { airConDto.DevicePower = !airConDto.DevicePower; await webAPIService.ChangeStateOfAirCon(airConDto); }