Do not allow team assignment when other teams exist already
This commit is contained in:
@@ -297,8 +297,17 @@
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudTooltip Text="This will overwrite existing teams">
|
||||
<MudButton Class="ma-3" StartIcon="@Icons.Material.Filled.Warning" Variant="Variant.Filled" Size="Size.Large" OnClick="SaveTeams" Color="Color.Warning">Save</MudButton>
|
||||
@if (_hasExistingTeams)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Class="ma-3" Variant="Variant.Filled">
|
||||
<strong>Cannot save:</strong> There are existing teams. Please delete all teams before saving a new assignment.
|
||||
<MudButton Href="/teams" Variant="Variant.Text" Color="Color.Default" Class="ml-2">View Teams</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
<MudTooltip Text="@(_hasExistingTeams ? "Delete existing teams first" : "This will save the team assignments")">
|
||||
<MudButton Class="ma-3" StartIcon="@Icons.Material.Filled.Warning" Variant="Variant.Filled" Size="Size.Large"
|
||||
OnClick="SaveTeams" Color="Color.Warning" Disabled="@_hasExistingTeams">Save</MudButton>
|
||||
</MudTooltip>
|
||||
@code {
|
||||
public bool TestSwitch { get; set; } = false;
|
||||
@@ -323,6 +332,7 @@
|
||||
private string _solutionStatus = string.Empty;
|
||||
|
||||
private bool _isSolving = false;
|
||||
private bool _hasExistingTeams = false;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -330,13 +340,16 @@
|
||||
await Context.Events
|
||||
.OrderBy(e => e.Name)
|
||||
.ToListAsync();
|
||||
_students =
|
||||
_students =
|
||||
await Context.Students
|
||||
.Where(e => e.FirstName != "test")
|
||||
.Include(e => e.EventRankings)
|
||||
.ThenInclude(e => e.EventDefinition)
|
||||
.Where(e => e.EventRankings.Any())
|
||||
.OrderBy(e => e.FirstName).ToListAsync();
|
||||
|
||||
// Check if there are existing teams
|
||||
_hasExistingTeams = await Context.Teams.AnyAsync();
|
||||
}
|
||||
|
||||
private async Task AddTeam()
|
||||
|
||||
Reference in New Issue
Block a user