private async void BtnEditEmployee_Click(object sender, RoutedEventArgs e) { UserApiService service = new UserApiService(); int userid = 0; try { RefreshLabels(); if (dgShowEmployees.SelectedItem != null) { userid = (dgShowEmployees.SelectedItem as UserVM).Id; } string req = await service.UpdateAsync(new UserUpdateVM { Id = userid, Name = txtName.Text, Email = txtEmail.Text }); MessageBox.Show("Працівник відредагований успішно."); txtEmail.Text = ""; txtName.Text = ""; FillDG(); dgShowEmployees.SelectedItem = null; } catch (WebException wex) { ShowException(wex); } }