Do not allow team assignment when other teams exist already
This commit is contained in:
@@ -297,8 +297,17 @@
|
|||||||
</MudItem>
|
</MudItem>
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
|
|
||||||
<MudTooltip Text="This will overwrite existing teams">
|
@if (_hasExistingTeams)
|
||||||
<MudButton Class="ma-3" StartIcon="@Icons.Material.Filled.Warning" Variant="Variant.Filled" Size="Size.Large" OnClick="SaveTeams" Color="Color.Warning">Save</MudButton>
|
{
|
||||||
|
<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>
|
</MudTooltip>
|
||||||
@code {
|
@code {
|
||||||
public bool TestSwitch { get; set; } = false;
|
public bool TestSwitch { get; set; } = false;
|
||||||
@@ -323,6 +332,7 @@
|
|||||||
private string _solutionStatus = string.Empty;
|
private string _solutionStatus = string.Empty;
|
||||||
|
|
||||||
private bool _isSolving = false;
|
private bool _isSolving = false;
|
||||||
|
private bool _hasExistingTeams = false;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@@ -337,6 +347,9 @@
|
|||||||
.ThenInclude(e => e.EventDefinition)
|
.ThenInclude(e => e.EventDefinition)
|
||||||
.Where(e => e.EventRankings.Any())
|
.Where(e => e.EventRankings.Any())
|
||||||
.OrderBy(e => e.FirstName).ToListAsync();
|
.OrderBy(e => e.FirstName).ToListAsync();
|
||||||
|
|
||||||
|
// Check if there are existing teams
|
||||||
|
_hasExistingTeams = await Context.Teams.AnyAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AddTeam()
|
private async Task AddTeam()
|
||||||
|
|||||||
Reference in New Issue
Block a user