Person.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. using Jellyfin.Data.Interfaces;
  6. namespace Jellyfin.Data.Entities.Libraries
  7. {
  8. /// <summary>
  9. /// An entity representing a person.
  10. /// </summary>
  11. public class Person : IHasConcurrencyToken
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="Person"/> class.
  15. /// </summary>
  16. /// <param name="name">The name of the person.</param>
  17. public Person(string name)
  18. {
  19. if (string.IsNullOrEmpty(name))
  20. {
  21. throw new ArgumentNullException(nameof(name));
  22. }
  23. Name = name;
  24. DateAdded = DateTime.UtcNow;
  25. DateModified = DateAdded;
  26. Sources = new HashSet<MetadataProviderId>();
  27. }
  28. /// <summary>
  29. /// Initializes a new instance of the <see cref="Person"/> class.
  30. /// </summary>
  31. /// <remarks>
  32. /// Default constructor. Protected due to required properties, but present because EF needs it.
  33. /// </remarks>
  34. protected Person()
  35. {
  36. }
  37. /// <summary>
  38. /// Gets or sets the id.
  39. /// </summary>
  40. /// <remarks>
  41. /// Identity, Indexed, Required.
  42. /// </remarks>
  43. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  44. public int Id { get; protected set; }
  45. /// <summary>
  46. /// Gets or sets the name.
  47. /// </summary>
  48. /// <remarks>
  49. /// Required, Max length = 1024.
  50. /// </remarks>
  51. [Required]
  52. [MaxLength(1024)]
  53. [StringLength(1024)]
  54. public string Name { get; set; }
  55. /// <summary>
  56. /// Gets or sets the source id.
  57. /// </summary>
  58. /// <remarks>
  59. /// Max length = 255.
  60. /// </remarks>
  61. [MaxLength(256)]
  62. [StringLength(256)]
  63. public string SourceId { get; set; }
  64. /// <summary>
  65. /// Gets or sets the date added.
  66. /// </summary>
  67. /// <remarks>
  68. /// Required.
  69. /// </remarks>
  70. public DateTime DateAdded { get; protected set; }
  71. /// <summary>
  72. /// Gets or sets the date modified.
  73. /// </summary>
  74. /// <remarks>
  75. /// Required.
  76. /// </remarks>
  77. public DateTime DateModified { get; set; }
  78. /// <inheritdoc />
  79. [ConcurrencyCheck]
  80. public uint RowVersion { get; set; }
  81. /// <summary>
  82. /// Gets or sets a list of metadata sources for this person.
  83. /// </summary>
  84. public virtual ICollection<MetadataProviderId> Sources { get; protected set; }
  85. /// <inheritdoc />
  86. public void OnSavingChanges()
  87. {
  88. RowVersion++;
  89. }
  90. }
  91. }