Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dcd9e5aab | ||
|
|
336bbb1dec |
@@ -1,5 +1,9 @@
|
||||
@using WebApp.Models
|
||||
@using WebApp.Models
|
||||
|
||||
@if (EventDefinition is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@* @if (EventDefinition.LevelOfEffort.HasValue)
|
||||
{
|
||||
<span class="numberCircle">@EventDefinition.LevelOfEffort</span>
|
||||
@@ -27,12 +31,17 @@
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public required EventDefinition EventDefinition { get; set; }
|
||||
public EventDefinition? EventDefinition { get; set; }
|
||||
|
||||
private string _attributes = string.Empty;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (EventDefinition is null)
|
||||
{
|
||||
_attributes = string.Empty;
|
||||
return;
|
||||
}
|
||||
_attributes = EventDefinition.EventFormat == EventFormat.Individual ? AppIcons.IndividualEvent : " ";
|
||||
_attributes += EventDefinition.OnSiteActivity ? AppIcons.OnSiteActivity : " ";
|
||||
_attributes += EventDefinition.RegionalEvent ? AppIcons.RegionalEvent : " ";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/events/edit"
|
||||
@page "/events/edit"
|
||||
@attribute [Authorize]
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using WebApp.Components.Shared.Components
|
||||
@@ -163,9 +163,10 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the tracked entity from the database
|
||||
// Get the tracked entity from the database (do not Include RelatedCareers:
|
||||
// the same context may already be tracking those Career instances from the initial load,
|
||||
// which would cause "another instance with the same key value is already being tracked").
|
||||
var trackedEntity = await context.Events
|
||||
.Include(e => e.RelatedCareers)
|
||||
.FirstOrDefaultAsync(e => e.Id == EventDefinition!.Id);
|
||||
|
||||
if (trackedEntity == null)
|
||||
@@ -177,6 +178,8 @@
|
||||
|
||||
// Update scalar properties from the form-bound entity
|
||||
context.Entry(trackedEntity).CurrentValues.SetValues(EventDefinition!);
|
||||
// RelatedCareersText is not mapped; copy it so ProcessRelatedCareersAsync can use it
|
||||
trackedEntity.RelatedCareersText = EventDefinition!.RelatedCareersText;
|
||||
|
||||
// Normalize and process related careers
|
||||
await EventDefinitionService.ProcessRelatedCareersAsync(trackedEntity);
|
||||
|
||||
@@ -87,6 +87,13 @@
|
||||
AddTooltip="Add regional event teams"
|
||||
RemoveTooltip="Remove regional event teams" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" lg="4">
|
||||
<AddRemoveFilter Label="Presubmission"
|
||||
OnAdd="AddPresubmission"
|
||||
OnRemove="RemovePresubmission"
|
||||
AddTooltip="Add teams whose events require presubmission"
|
||||
RemoveTooltip="Remove teams whose events require presubmission" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" lg="4">
|
||||
<AddRemoveFilter Label="Individual"
|
||||
OnAdd="AddIndividual"
|
||||
@@ -246,6 +253,13 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void AddPresubmission()
|
||||
{
|
||||
var presubmissionTeams = _teams.Where(t => t.Event?.Presubmission == true);
|
||||
_scheduledTeams = _scheduledTeams.Concat(presubmissionTeams).Distinct();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void AddHighLevelOfEffort()
|
||||
{
|
||||
_scheduledTeams = _scheduledTeams.AddHighLevelOfEffort(_teams);
|
||||
@@ -266,6 +280,16 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void RemovePresubmission()
|
||||
{
|
||||
var presubmissionTeamIds = _teams
|
||||
.Where(t => t.Event?.Presubmission == true)
|
||||
.Select(t => t.Id)
|
||||
.ToHashSet();
|
||||
_scheduledTeams = _scheduledTeams.Where(t => !presubmissionTeamIds.Contains(t.Id));
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void AddIndividual()
|
||||
{
|
||||
var individualTeams = _teams.Where(t => t.Event.EventFormat == EventFormat.Individual);
|
||||
|
||||
@@ -244,6 +244,8 @@ else
|
||||
.AsNoTracking()
|
||||
.Include(e => e.Teams)
|
||||
.ThenInclude(e => e.Captain)
|
||||
.Include(e => e.Teams)
|
||||
.ThenInclude(e => e.Event)
|
||||
.Include(e => e.EventRankings)
|
||||
.ThenInclude(e => e.EventDefinition)
|
||||
.OrderBy(e => e.FirstName).ToArrayAsync();
|
||||
|
||||
@@ -38,9 +38,11 @@ public class EventDefinitionService
|
||||
return;
|
||||
}
|
||||
|
||||
// Get all existing careers from database (case-insensitive lookup)
|
||||
// Get existing careers with tracking so we use the same instances the context
|
||||
// may already be tracking (e.g. from the event's RelatedCareers). Using
|
||||
// AsNoTracking() would create duplicate instances and cause "another instance
|
||||
// with the same key value is already being tracked".
|
||||
var existingCareers = await _context.Careers
|
||||
.AsNoTracking()
|
||||
.Where(c => !string.IsNullOrWhiteSpace(c.Name))
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user