2aaefb2491
This commit introduces a new static file caching strategy in Program.cs, optimizing cache headers for Blazor assets to improve performance and ensure fresh content after deployments. Additionally, the Calendar component in Index.razor has been updated to include comprehensive logging for event loading, handling null occurrences, and error management during calendar item creation. The CalendarEventItem model is also initialized to prevent null reference issues. These changes enhance the application's reliability and user experience.
60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using Heron.MudCalendar;
|
|
using MudBlazor;
|
|
|
|
namespace WebApp.Models;
|
|
|
|
/// <summary>
|
|
/// Calendar event item model for Heron.MudCalendar component.
|
|
/// Maps from EventOccurrence entity to calendar event format.
|
|
/// </summary>
|
|
public class CalendarEventItem : CalendarItem
|
|
{
|
|
/// <summary>
|
|
/// Gets the original EventOccurrence data.
|
|
/// </summary>
|
|
public Core.Entities.EventOccurrence? EventOccurrenceData { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets the associated EventDefinition if available.
|
|
/// </summary>
|
|
public Core.Entities.EventDefinition? EventDefinition { get; set; }
|
|
|
|
/// <summary>
|
|
/// Parameterless constructor required by Heron.MudCalendar component.
|
|
/// </summary>
|
|
public CalendarEventItem()
|
|
{
|
|
// Initialize base class properties to avoid null reference issues
|
|
Text = string.Empty;
|
|
Start = DateTime.MinValue;
|
|
End = DateTime.MinValue;
|
|
}
|
|
|
|
public CalendarEventItem(Core.Entities.EventOccurrence occurrence, Core.Entities.EventDefinition? eventDefinition = null)
|
|
{
|
|
// Set base class properties that the calendar component uses
|
|
Text = GetEventTitle(occurrence, eventDefinition);
|
|
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;
|
|
}
|
|
}
|