private async void DeleteElementButtonClick(object sender, RoutedEventArgs e) { if (ModelsDataGrid.SelectedIndex == -1) { return; } await using var dbContext = new ApplicationContext(); var selectedRow = ModelsDataGrid.SelectedItem; var model = selectedRow as IModelWithoutUser ?? throw new ArgumentException(nameof(selectedRow)); dbContext.Models.Remove(new Model { Id = model.Id }); await dbContext.SaveChangesAsync(); await ModelsDataGrid.ReloadModelsTableAsync(); }
private async void LoadModels(object sender, EventArgs e) { await ModelsDataGrid.ReloadModelsTableAsync(); }