Person.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. /// Gets the id.
  30. /// </summary>
  31. /// <remarks>
  32. /// Identity, Indexed, Required.
  33. /// </remarks>
  34. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  35. public int Id { get; private set; }
  36. /// <summary>
  37. /// Gets or sets the name.
  38. /// </summary>
  39. /// <remarks>
  40. /// Required, Max length = 1024.
  41. /// </remarks>
  42. [MaxLength(1024)]
  43. [StringLength(1024)]
  44. public string Name { get; set; }
  45. /// <summary>
  46. /// Gets or sets the source id.
  47. /// </summary>
  48. /// <remarks>
  49. /// Max length = 255.
  50. /// </remarks>
  51. [MaxLength(256)]
  52. [StringLength(256)]
  53. public string? SourceId { get; set; }
  54. /// <summary>
  55. /// Gets the date added.
  56. /// </summary>
  57. /// <remarks>
  58. /// Required.
  59. /// </remarks>
  60. public DateTime DateAdded { get; private set; }
  61. /// <summary>
  62. /// Gets or sets the date modified.
  63. /// </summary>
  64. /// <remarks>
  65. /// Required.
  66. /// </remarks>
  67. public DateTime DateModified { get; set; }
  68. /// <inheritdoc />
  69. [ConcurrencyCheck]
  70. public uint RowVersion { get; private set; }
  71. /// <summary>
  72. /// Gets a list of metadata sources for this person.
  73. /// </summary>
  74. public virtual ICollection<MetadataProviderId> Sources { get; private set; }
  75. /// <inheritdoc />
  76. public void OnSavingChanges()
  77. {
  78. RowVersion++;
  79. }
  80. }
  81. }