Artwork.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Jellyfin.Data.Enums;
  5. using Jellyfin.Data.Interfaces;
  6. namespace Jellyfin.Data.Entities.Libraries
  7. {
  8. /// <summary>
  9. /// An entity representing artwork.
  10. /// </summary>
  11. public class Artwork : IHasConcurrencyToken
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="Artwork"/> class.
  15. /// </summary>
  16. /// <param name="path">The path.</param>
  17. /// <param name="kind">The kind of art.</param>
  18. /// <param name="owner">The owner.</param>
  19. public Artwork(string path, ArtKind kind, IHasArtwork owner)
  20. {
  21. if (string.IsNullOrEmpty(path))
  22. {
  23. throw new ArgumentNullException(nameof(path));
  24. }
  25. Path = path;
  26. Kind = kind;
  27. owner?.Artwork.Add(this);
  28. }
  29. /// <summary>
  30. /// Initializes a new instance of the <see cref="Artwork"/> class.
  31. /// </summary>
  32. /// <remarks>
  33. /// Default constructor. Protected due to required properties, but present because EF needs it.
  34. /// </remarks>
  35. protected Artwork()
  36. {
  37. }
  38. /// <summary>
  39. /// Gets or sets the id.
  40. /// </summary>
  41. /// <remarks>
  42. /// Identity, Indexed, Required.
  43. /// </remarks>
  44. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  45. public int Id { get; protected set; }
  46. /// <summary>
  47. /// Gets or sets the path.
  48. /// </summary>
  49. /// <remarks>
  50. /// Required, Max length = 65535.
  51. /// </remarks>
  52. [Required]
  53. [MaxLength(65535)]
  54. [StringLength(65535)]
  55. public string Path { get; set; }
  56. /// <summary>
  57. /// Gets or sets the kind of artwork.
  58. /// </summary>
  59. /// <remarks>
  60. /// Required.
  61. /// </remarks>
  62. public ArtKind Kind { get; set; }
  63. /// <inheritdoc />
  64. [ConcurrencyCheck]
  65. public uint RowVersion { get; set; }
  66. /// <inheritdoc />
  67. public void OnSavingChanges()
  68. {
  69. RowVersion++;
  70. }
  71. }
  72. }