#pragma warning disable CA2227 using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Jellyfin.Data.Interfaces; namespace Jellyfin.Data.Entities.Libraries { /// /// An entity representing a chapter. /// public class Chapter : IHasConcurrencyToken { /// /// Initializes a new instance of the class. /// /// ISO-639-3 3-character language codes. /// The start time for this chapter. /// The release. public Chapter(string language, long startTime, Release release) { if (string.IsNullOrEmpty(language)) { throw new ArgumentNullException(nameof(language)); } Language = language; StartTime = startTime; if (release == null) { throw new ArgumentNullException(nameof(release)); } release.Chapters.Add(this); } /// /// Initializes a new instance of the class. /// /// /// Default constructor. Protected due to required properties, but present because EF needs it. /// protected Chapter() { } /// /// Gets or sets the id. /// /// /// Identity, Indexed, Required. /// [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; protected set; } /// /// Gets or sets the name. /// /// /// Max length = 1024. /// [MaxLength(1024)] [StringLength(1024)] public string Name { get; set; } /// /// Gets or sets the language. /// /// /// Required, Min length = 3, Max length = 3 /// ISO-639-3 3-character language codes. /// [Required] [MinLength(3)] [MaxLength(3)] [StringLength(3)] public string Language { get; set; } /// /// Gets or sets the start time. /// /// /// Required. /// public long StartTime { get; set; } /// /// Gets or sets the end time. /// public long? EndTime { get; set; } /// [ConcurrencyCheck] public uint RowVersion { get; protected set; } /// public void OnSavingChanges() { RowVersion++; } } }