Enhance calendar import functionality with null safety checks

This commit updates the Import.razor component to include a cast to non-nullable strings after filtering locations, ensuring that only valid strings are processed. Additionally, the Index.razor component is modified to handle null event definitions gracefully by providing an empty list of student first names when the event definition is null. These changes improve the robustness and reliability of the calendar import feature.
This commit is contained in:
2026-01-10 19:08:11 -05:00
parent e77f34ff9f
commit 37e82646b8
2 changed files with 4 additions and 1 deletions
@@ -155,6 +155,7 @@
.SelectMany(list => list)
.Select(eo => eo.Location)
.Where(loc => !string.IsNullOrWhiteSpace(loc))
.Cast<string>() // Cast to non-nullable string after null check
.Distinct()
.OrderBy(loc => loc)
.ToList();
@@ -110,7 +110,9 @@
}
// Get student first names for this event definition
var studentFirstNames = StudentFirstNames(occ.EventDefinition, teamsByEventId);
var studentFirstNames = occ.EventDefinition != null
? StudentFirstNames(occ.EventDefinition, teamsByEventId)
: new List<string>();
var calendarItem = new CalendarEventItem(occ, studentFirstNames);
items.Add(calendarItem);