private async void OkButton_Click(object sender, RoutedEventArgs e) { var entity = _id == 0 ? new Tool() : await _toolService.GetAsync(_id); entity.Name = NameTextBox.Text; entity.Application = ApplicationTextBox.Text; try { if (_id == 0) { await _toolService.CreateAsync(entity); } else { await _toolService.UpdateAsync(entity); } MainWindow.PublicToolDataGrid.ItemsSource = await _toolService.GetAllAsync(); Close(); } catch (Exception exception) { MessageBox.Show("Server error"); } }