Refactor Delete
Add Scheduler
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using WebApp.Models
|
||||
@inject AppDbContext Context
|
||||
@inject IDialogService DialogService
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<PageTitle>TimeSlots</PageTitle>
|
||||
|
||||
@@ -11,6 +13,7 @@
|
||||
<MudButton StartIcon="@Icons.Material.Filled.Assignment" Href="teams/assignment">Assignment</MudButton>
|
||||
<MudButton StartIcon="@Icons.Material.Filled.Print" Href="teams/printout">Printout</MudButton>
|
||||
|
||||
|
||||
<MudDataGrid T="Team" ServerData="ServerReload" @ref="_dataGrid" Filterable="true" RowsPerPage="35">
|
||||
<Columns>
|
||||
<PropertyColumn Property="@(e => e.ToString())" Title="Event" />
|
||||
@@ -51,7 +54,9 @@
|
||||
<MudIconButton Href="@($"/teams/edit?id={context.Item.Id}")" Icon="@Icons.Material.Filled.Edit">Edit</MudIconButton>
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Delete">
|
||||
<MudIconButton Href="@($"/teams/delete?id={context.Item.Id}")" Icon="@Icons.Material.Filled.Delete" Color="@Color.Warning">Delete</MudIconButton>
|
||||
<MudIconButton Icon="@Icons.Material.Outlined.Delete"
|
||||
Color="Color.Error"
|
||||
OnClick="() => DeleteTeam(context.Item)" />
|
||||
</MudTooltip>
|
||||
</MudButtonGroup>
|
||||
</MudStack>
|
||||
@@ -87,4 +92,26 @@
|
||||
Items = pagedData
|
||||
};
|
||||
}
|
||||
|
||||
private async Task DeleteTeam(Team team)
|
||||
{
|
||||
//_isRowBlocked = true;
|
||||
|
||||
var result = await DialogService
|
||||
.ShowMessageBox("Delete team",
|
||||
(MarkupString)$"Are you sure want to delete <b>{team}</b>? This cannot be undone.",
|
||||
yesText: "Yes",
|
||||
noText: "Cancel");
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
Context.Teams.Remove(team!);
|
||||
await Context.SaveChangesAsync();
|
||||
Snackbar.Add($"Delete event: Delete of Team {team}", Severity.Info);
|
||||
}
|
||||
|
||||
//_isRowBlocked = false;
|
||||
StateHasChanged();
|
||||
_dataGrid.ReloadServerData();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user