Refactor event occurrence parsing to unify section header handling and event count tracking
This commit updates the EventOccurrenceParseResult and EventOccurrenceParserResult classes to consolidate the handling of skipped section headers and event counts into a single set of properties. The previous separate lists and counts for middle school and high school sections have been replaced with a unified approach, improving clarity and maintainability. Additionally, the EventOccurrenceParserService has been modified to reflect these changes, ensuring consistent behavior across the application. This refactor enhances the overall structure of the event parsing logic.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using Core.Entities;
|
||||
using Heron.MudCalendar;
|
||||
using MudBlazor;
|
||||
|
||||
namespace WebApp.Models;
|
||||
|
||||
@@ -12,12 +12,17 @@ public class CalendarEventItem : CalendarItem
|
||||
/// <summary>
|
||||
/// Gets the original EventOccurrence data.
|
||||
/// </summary>
|
||||
public Core.Entities.EventOccurrence? EventOccurrenceData { get; set; }
|
||||
public EventOccurrence? EventOccurrenceData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the associated EventDefinition if available.
|
||||
/// </summary>
|
||||
public Core.Entities.EventDefinition? EventDefinition { get; set; }
|
||||
public EventDefinition? EventDefinition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of student first names from teams matching the EventDefinition.
|
||||
/// </summary>
|
||||
public List<string> StudentFirstNames { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor required by Heron.MudCalendar component.
|
||||
@@ -30,30 +35,15 @@ public class CalendarEventItem : CalendarItem
|
||||
End = DateTime.MinValue;
|
||||
}
|
||||
|
||||
public CalendarEventItem(Core.Entities.EventOccurrence occurrence, Core.Entities.EventDefinition? eventDefinition = null)
|
||||
public CalendarEventItem(EventOccurrence occurrence, IEnumerable<string>? studentFirstNames = null)
|
||||
{
|
||||
EventOccurrenceData = occurrence;
|
||||
EventDefinition = occurrence.EventDefinition;
|
||||
// Set base class properties that the calendar component uses
|
||||
Text = GetEventTitle(occurrence, eventDefinition);
|
||||
StudentFirstNames = studentFirstNames?.ToList() ?? [];
|
||||
Text = occurrence.EventDefinition?.ShortName;
|
||||
Start = occurrence.StartTime;
|
||||
End = occurrence.EndTime ?? occurrence.StartTime.AddHours(1);
|
||||
this.EventOccurrenceData = occurrence;
|
||||
this.EventDefinition = eventDefinition;
|
||||
}
|
||||
|
||||
private static string GetEventTitle(Core.Entities.EventOccurrence occurrence, Core.Entities.EventDefinition? eventDefinition)
|
||||
{
|
||||
var title = occurrence.Name;
|
||||
|
||||
if (eventDefinition != null && !string.IsNullOrEmpty(eventDefinition.Name))
|
||||
{
|
||||
title = $"{eventDefinition.Name} - {title}";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(occurrence.Location))
|
||||
{
|
||||
title += $" ({occurrence.Location})";
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user