Add ability to delete games

This commit is contained in:
Pat Hartl 2023-03-15 18:09:48 -05:00
parent 42db70e3f5
commit 659cfda497

View file

@ -25,10 +25,15 @@
@context.UpdatedBy?.UserName @context.UpdatedBy?.UserName
</PropertyColumn> </PropertyColumn>
<ActionColumn Title=""> <ActionColumn Title="">
<Space> <Space Direction="DirectionVHType.Horizontal">
<SpaceItem> <SpaceItem>
<Button OnClick="() => Edit(context)">Edit</Button> <Button OnClick="() => Edit(context)">Edit</Button>
</SpaceItem> </SpaceItem>
<SpaceItem>
<Popconfirm OnConfirm="() => Delete(context)" Title="Are you sure you want to delete this game?">
<Button Icon="@IconType.Outline.Close" Type="@ButtonType.Text" Danger />
</Popconfirm>
</SpaceItem>
</Space> </Space>
</ActionColumn> </ActionColumn>
</Table> </Table>
@ -64,4 +69,17 @@
{ {
NavigationManager.NavigateTo($"/Games/{game.Id}/Edit"); NavigationManager.NavigateTo($"/Games/{game.Id}/Edit");
} }
private async Task Delete(Game game)
{
Games = new List<Game>();
Loading = true;
await GameService.Delete(game);
Games = GameService.Get().OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToList();
Loading = false;
}
} }