Refactor collection initializers to use C# 12 collection expressions
This commit updates various files across the Core and WebApp projects to replace traditional collection initializers with C# 12 collection expressions. Changes include modifications to EventAssignment.cs, TeamScheduler_DecisionTree.cs, CareerField.cs, EventDefinition.cs, and several components in the WebApp. These updates enhance code readability and maintainability by adhering to modern C# syntax standards.
This commit is contained in:
@@ -99,7 +99,7 @@
|
||||
// Load teams for all event definitions
|
||||
var teamsByEventId = await EventOccurrenceService.GetTeamsByEventDefinitionIdsAsync(eventDefinitionIds);
|
||||
|
||||
var items = new List<CalendarEventItem>();
|
||||
List<CalendarEventItem> items = [];
|
||||
foreach (var occ in eventOccurrences)
|
||||
{
|
||||
try
|
||||
@@ -112,7 +112,7 @@
|
||||
// Get student first names for this event definition
|
||||
var studentFirstNames = occ.EventDefinition != null
|
||||
? StudentFirstNames(occ.EventDefinition, teamsByEventId)
|
||||
: new List<string>();
|
||||
: [];
|
||||
|
||||
var calendarItem = new CalendarEventItem(occ, studentFirstNames);
|
||||
items.Add(calendarItem);
|
||||
@@ -135,7 +135,7 @@
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error loading calendar events");
|
||||
_calendarItems = new List<CalendarEventItem>();
|
||||
_calendarItems = [];
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -145,7 +145,7 @@
|
||||
|
||||
private static List<string> StudentFirstNames(EventDefinition ed, Dictionary<int, List<Team>> teamsByEventId)
|
||||
{
|
||||
var studentFirstNames = new List<string>();
|
||||
List<string> studentFirstNames = [];
|
||||
if (ed?.Id == null || !teamsByEventId.TryGetValue(ed.Id, out var teams)) return studentFirstNames;
|
||||
|
||||
// Get all unique student first names from all teams for this event
|
||||
@@ -220,7 +220,7 @@
|
||||
|
||||
private string GetEventTooltip(CalendarEventItem item)
|
||||
{
|
||||
var parts = new List<string>();
|
||||
List<string> parts = [];
|
||||
|
||||
if (!string.IsNullOrEmpty(item.EventDefinition?.Name))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user