Delete Edit @inject IArtifactGroupingProvider GroupingProvider; @inject IDialogService DialogService; @inject IArtifactGroupingProvider GroupingProvider; @code { public List ArtifactGroupingRows { get; set; } = new(); public MudDataGrid DataGrid { get; set; } = default!; protected override async Task OnInitializedAsync() { // Load inital data List groupings = await GroupingProvider.GetGroupingsPaged(1, 25); SetGroupingRows(groupings); await base.OnInitializedAsync(); StateHasChanged(); } private void SetGroupingRows(IEnumerable groupings) { ArtifactGroupingRows.Clear(); foreach (var grouping in groupings) { ArtifactGroupingRows.Add(new ArtifactGroupingRowElement() { ArtifactGroupingIdentifier=grouping.ArtifactGroupingIdentifier ?? throw new ArgumentNullException(nameof(grouping), "Got a null grouping identifier"), CategoryName=grouping.Category.Name, Title=grouping.Title, IsPublicallyVisible=grouping.IsPublicallyVisible, Id=grouping.Id } ); } } private void OnRowEditClick(ArtifactGroupingRowElement row) { throw new NotImplementedException(); } private async Task OnDeleteClicked(MouseEventArgs args) { HashSet selected = DataGrid.SelectedItems; bool? confirmed = await DialogService.ShowMessageBox ( new MessageBoxOptions(){ Message=$"Are you sure you want to delete {selected.Count} groupings?", Title="Delete Groupings", CancelText="Cancel", YesText="Delete" }); if (confirmed is not null && (confirmed ?? throw new ArgumentNullException("confirmed was null"))) { foreach (var grouping in selected) { await GroupingProvider.DeleteGroupingAsync(grouping.Id); StateHasChanged(); } } } }