Refactor Delete

Add Scheduler
This commit is contained in:
2025-10-03 09:29:28 -04:00
parent 338eab0294
commit 9152c86d41
14 changed files with 517 additions and 389 deletions
@@ -3,6 +3,7 @@
@using WebApp.Models
@inject AppDbContext Context
@inject IDialogService DialogService
@inject ISnackbar Snackbar
<PageTitle>Students - TSA Chapter Organizer</PageTitle>
@@ -41,8 +42,7 @@
<MudTooltip Text="Delete">
<MudIconButton Icon="@Icons.Material.Outlined.Delete"
Color="Color.Error"
OnClick="() => DeleteElement(context.Item)" />
OnClick="() => DeleteStudent(context.Item)" />
</MudTooltip>
</MudButtonGroup>
</MudStack>
@@ -74,24 +74,21 @@
};
}
private async Task DeleteElement(object obj)
private async Task DeleteStudent(Student student)
{
//_isRowBlocked = true;
if (obj is Student student)
{
var result = await DialogService
.ShowMessageBox("Delete student",
(MarkupString)$"Are you sure want to delete <b>{student.Name}</b>?",
yesText:"Yes",
noText:"Cancel");
var result = await DialogService
.ShowMessageBox("Delete student",
(MarkupString)$"Are you sure want to delete <b>{student.Name}</b>? This cannot be undone.",
yesText:"Yes",
noText:"Cancel");
if (result == true)
{
Context.Students.Remove(student!);
await Context.SaveChangesAsync();
//Snackbar.Add($"Delete event: Delete of Element {element.Name}", Severity.Info);
}
if (result == true)
{
Context.Students.Remove(student!);
await Context.SaveChangesAsync();
Snackbar.Add($"Delete event: Delete of Student {student.Name}", Severity.Info);
}
//_isRowBlocked = false;