From 37e82646b8905ff4b97e78445cca27838c74c79d Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Sat, 10 Jan 2026 19:08:11 -0500 Subject: [PATCH] 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. --- WebApp/Components/Features/Calendar/Import.razor | 1 + WebApp/Components/Features/Calendar/Index.razor | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/WebApp/Components/Features/Calendar/Import.razor b/WebApp/Components/Features/Calendar/Import.razor index 569b508..9163457 100644 --- a/WebApp/Components/Features/Calendar/Import.razor +++ b/WebApp/Components/Features/Calendar/Import.razor @@ -155,6 +155,7 @@ .SelectMany(list => list) .Select(eo => eo.Location) .Where(loc => !string.IsNullOrWhiteSpace(loc)) + .Cast() // Cast to non-nullable string after null check .Distinct() .OrderBy(loc => loc) .ToList(); diff --git a/WebApp/Components/Features/Calendar/Index.razor b/WebApp/Components/Features/Calendar/Index.razor index 32882d6..3d593ba 100644 --- a/WebApp/Components/Features/Calendar/Index.razor +++ b/WebApp/Components/Features/Calendar/Index.razor @@ -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(); var calendarItem = new CalendarEventItem(occ, studentFirstNames); items.Add(calendarItem);