private async void OnUpdate(object sender, EventArgs e) { Models.Devices.Device device = _devices[0]; device.NameDevice += " [updated]"; string content = JsonConvert.SerializeObject(device); await _client.PutAsync(Url + "/" + device.IdDevice, new StringContent(content, Encoding.UTF8, "application/json")); }
private async void OnDelete(object sender, EventArgs e) { Models.Devices.Device device = _devices[0]; await _client.DeleteAsync(Url + "/" + device.IdDevice); _devices.Remove(device); }
private async void OnAdd(object sender, EventArgs e) { Models.Devices.Device device = new Models.Devices.Device { NameDevice = $"{DateTime.UtcNow}" }; string content = JsonConvert.SerializeObject(device); await _client.PostAsync(Url, new StringContent(content, Encoding.UTF8, "application/json")); _devices.Insert(0, device); }