using Core.Entities;
using Heron.MudCalendar;
namespace WebApp.Models;
///
/// Calendar event item model for Heron.MudCalendar component.
/// Maps from EventOccurrence entity to calendar event format.
///
public class CalendarEventItem : CalendarItem
{
///
/// Gets the original EventOccurrence data.
///
public EventOccurrence? EventOccurrenceData { get; set; }
///
/// Gets the associated EventDefinition if available.
///
public EventDefinition? EventDefinition { get; set; }
///
/// Gets the list of student first names from teams matching the EventDefinition.
///
public List StudentFirstNames { get; set; } = [];
///
/// Parameterless constructor required by Heron.MudCalendar component.
///
public CalendarEventItem()
{
// Initialize base class properties to avoid null reference issues
Text = string.Empty;
Start = DateTime.MinValue;
End = DateTime.MinValue;
}
public CalendarEventItem(EventOccurrence occurrence, IEnumerable? studentFirstNames = null)
{
EventOccurrenceData = occurrence;
EventDefinition = occurrence.EventDefinition;
// Set base class properties that the calendar component uses
StudentFirstNames = studentFirstNames?.ToList() ?? [];
Text = occurrence.EventDefinition?.ShortName ?? string.Empty;
Start = occurrence.StartTime;
End = occurrence.EndTime ?? occurrence.StartTime.AddHours(1);
}
}