Files
Elternbeirat/Elternbeirat.Contracts/Event.cs
T

72 lines
2.3 KiB
C#

using System.Text.Json.Serialization;
namespace Elternbeirat.Contracts;
/// <summary>
/// A calendar entry of the Elternbeirat, as stored in PocketBase.
/// </summary>
/// <remarks>
/// Event lists are ordered by <see cref="Start"/>. Unset optional text fields are
/// <see cref="string.Empty"/>, never <see langword="null"/>.
/// </remarks>
public record Event
{
/// <summary>
/// Gets the PocketBase record id.
/// </summary>
[JsonPropertyName("id")]
public string Id { get; init; } = "";
/// <summary>
/// Gets the start of the event as Europe/Berlin wall-clock time.
/// </summary>
/// <remarks>
/// PocketBase stores the value in UTC; it is converted to Berlin local time on
/// deserialization, with daylight saving applied. An all-day event uses 00:00
/// as the time.
/// </remarks>
[JsonPropertyName("start")]
[JsonConverter(typeof(LocalDateTimeConverter))]
public DateTime Start { get; init; }
/// <summary>
/// Gets the optional end of the event as Europe/Berlin wall-clock time.
/// </summary>
/// <value>
/// The end time, or <see langword="null"/> if the event has no end.
/// </value>
[JsonPropertyName("end")]
[JsonConverter(typeof(NullableLocalDateTimeConverter))]
public DateTime? End { get; init; }
/// <summary>
/// Gets the event name, e.g. <c>"Elternbeiratssitzung"</c>.
/// </summary>
[JsonPropertyName("title")]
public string Title { get; init; } = "";
/// <summary>
/// Gets the optional location, e.g. <c>"Aula"</c>.
/// </summary>
/// <value>
/// The location, or <see cref="string.Empty"/> if none is set.
/// </value>
[JsonPropertyName("location")]
public string Location { get; init; } = "";
/// <summary>
/// Gets the optional note, e.g. <c>"Anmeldung erforderlich"</c>.
/// </summary>
/// <value>
/// The note, or <see cref="string.Empty"/> if none is set.
/// </value>
[JsonPropertyName("note")]
public string Note { get; init; } = "";
/// <summary>
/// Gets a value indicating whether the event is visible to visitors of the site.
/// </summary>
[JsonPropertyName("public")]
public bool Public { get; init; }
}