@page "/students" @attribute [Authorize] @using Microsoft.EntityFrameworkCore @using WebApp.Models @inject AppDbContext Context @inject IDialogService DialogService @inject ISnackbar Snackbar Students - TSA Chapter Organizer Students Create New Event Rankings @* *@ @context.Item.LastNameFirstName @if (context.Item.OfficerRole != null) { @context.Item.OfficerRole } @context.Item.Grade (@context.Item.TsaYear) @code { MudDataGrid _dataGrid = null!; private async Task> ServerReload(GridState state) { var query = Context.Students.OrderBy(e => e.LastName) .Where(state.FilterDefinitions).OrderBy(state.SortDefinitions); var totalItems = await query.CountAsync(); var pagedData = await query.Skip(state.Page * state.PageSize).Take(state.PageSize).ToArrayAsync(); return new GridData { TotalItems = totalItems, Items = pagedData }; } private async Task DeleteStudent(Student student) { //_isRowBlocked = true; var result = await DialogService .ShowMessageBox("Delete student", (MarkupString)$"Are you sure want to delete {student.Name}? This cannot be undone.", yesText:"Yes", noText:"Cancel"); if (result == true) { Context.Students.Remove(student!); await Context.SaveChangesAsync(); Snackbar.Add($"Delete event: Delete of Student {student.Name}", Severity.Info); } //_isRowBlocked = false; StateHasChanged(); await _dataGrid.ReloadServerData(); } }