using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Jellyfin.Data.Enums; using Jellyfin.Data.Interfaces; namespace Jellyfin.Data.Entities.Libraries { /// /// An entity representing artwork. /// public class Artwork : IHasConcurrencyToken { /// /// Initializes a new instance of the class. /// /// The path. /// The kind of art. /// The owner. public Artwork(string path, ArtKind kind, IHasArtwork owner) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } Path = path; Kind = kind; owner?.Artwork.Add(this); } /// /// Initializes a new instance of the class. /// /// /// Default constructor. Protected due to required properties, but present because EF needs it. /// protected Artwork() { } /// /// Gets or sets the id. /// /// /// Identity, Indexed, Required. /// [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; protected set; } /// /// Gets or sets the path. /// /// /// Required, Max length = 65535. /// [Required] [MaxLength(65535)] [StringLength(65535)] public string Path { get; set; } /// /// Gets or sets the kind of artwork. /// /// /// Required. /// public ArtKind Kind { get; set; } /// [ConcurrencyCheck] public uint RowVersion { get; set; } /// public void OnSavingChanges() { RowVersion++; } } }