Person.cs 2.8 KB

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