| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.ComponentModel.DataAnnotations; |
| | | 4 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 5 | | using Jellyfin.Database.Implementations.Interfaces; |
| | | 6 | | |
| | | 7 | | namespace Jellyfin.Database.Implementations.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 | | { |
| | 0 | 20 | | ArgumentException.ThrowIfNullOrEmpty(name); |
| | | 21 | | |
| | 0 | 22 | | Name = name; |
| | 0 | 23 | | DateAdded = DateTime.UtcNow; |
| | 0 | 24 | | DateModified = DateAdded; |
| | | 25 | | |
| | 0 | 26 | | Sources = new HashSet<MetadataProviderId>(); |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Gets the id. |
| | | 31 | | /// </summary> |
| | | 32 | | /// <remarks> |
| | | 33 | | /// Identity, Indexed, Required. |
| | | 34 | | /// </remarks> |
| | | 35 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | | 36 | | public int Id { get; private set; } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Gets or sets the name. |
| | | 40 | | /// </summary> |
| | | 41 | | /// <remarks> |
| | | 42 | | /// Required, Max length = 1024. |
| | | 43 | | /// </remarks> |
| | | 44 | | [MaxLength(1024)] |
| | | 45 | | [StringLength(1024)] |
| | | 46 | | public string Name { get; set; } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// Gets or sets the source id. |
| | | 50 | | /// </summary> |
| | | 51 | | /// <remarks> |
| | | 52 | | /// Max length = 255. |
| | | 53 | | /// </remarks> |
| | | 54 | | [MaxLength(256)] |
| | | 55 | | [StringLength(256)] |
| | | 56 | | public string? SourceId { get; set; } |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Gets the date added. |
| | | 60 | | /// </summary> |
| | | 61 | | /// <remarks> |
| | | 62 | | /// Required. |
| | | 63 | | /// </remarks> |
| | | 64 | | public DateTime DateAdded { get; private set; } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Gets or sets the date modified. |
| | | 68 | | /// </summary> |
| | | 69 | | /// <remarks> |
| | | 70 | | /// Required. |
| | | 71 | | /// </remarks> |
| | | 72 | | public DateTime DateModified { get; set; } |
| | | 73 | | |
| | | 74 | | /// <inheritdoc /> |
| | | 75 | | [ConcurrencyCheck] |
| | | 76 | | public uint RowVersion { get; private set; } |
| | | 77 | | |
| | | 78 | | /// <summary> |
| | | 79 | | /// Gets a list of metadata sources for this person. |
| | | 80 | | /// </summary> |
| | | 81 | | public virtual ICollection<MetadataProviderId> Sources { get; private set; } |
| | | 82 | | |
| | | 83 | | /// <inheritdoc /> |
| | | 84 | | public void OnSavingChanges() |
| | | 85 | | { |
| | 0 | 86 | | RowVersion++; |
| | 0 | 87 | | } |
| | | 88 | | } |
| | | 89 | | } |