| | | 1 | | using System.Collections.Generic; |
| | | 2 | | using System.ComponentModel.DataAnnotations; |
| | | 3 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 4 | | using Jellyfin.Database.Implementations.Enums; |
| | | 5 | | using Jellyfin.Database.Implementations.Interfaces; |
| | | 6 | | |
| | | 7 | | namespace Jellyfin.Database.Implementations.Entities.Libraries |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// An entity representing a person's role in media. |
| | | 11 | | /// </summary> |
| | | 12 | | public class PersonRole : IHasArtwork, IHasConcurrencyToken |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Initializes a new instance of the <see cref="PersonRole"/> class. |
| | | 16 | | /// </summary> |
| | | 17 | | /// <param name="type">The role type.</param> |
| | | 18 | | /// <param name="person">The person.</param> |
| | | 19 | | public PersonRole(PersonRoleType type, Person person) |
| | | 20 | | { |
| | 0 | 21 | | Type = type; |
| | 0 | 22 | | Person = person; |
| | 0 | 23 | | Artwork = new HashSet<Artwork>(); |
| | 0 | 24 | | Sources = new HashSet<MetadataProviderId>(); |
| | 0 | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets the id. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <remarks> |
| | | 31 | | /// Identity, Indexed, Required. |
| | | 32 | | /// </remarks> |
| | | 33 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | | 34 | | public int Id { get; private set; } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets or sets the name of the person's role. |
| | | 38 | | /// </summary> |
| | | 39 | | /// <remarks> |
| | | 40 | | /// Max length = 1024. |
| | | 41 | | /// </remarks> |
| | | 42 | | [MaxLength(1024)] |
| | | 43 | | [StringLength(1024)] |
| | | 44 | | public string? Role { get; set; } |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Gets or sets the person's role type. |
| | | 48 | | /// </summary> |
| | | 49 | | /// <remarks> |
| | | 50 | | /// Required. |
| | | 51 | | /// </remarks> |
| | | 52 | | public PersonRoleType Type { get; set; } |
| | | 53 | | |
| | | 54 | | /// <inheritdoc /> |
| | | 55 | | [ConcurrencyCheck] |
| | | 56 | | public uint RowVersion { get; private set; } |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Gets or sets the person. |
| | | 60 | | /// </summary> |
| | | 61 | | /// <remarks> |
| | | 62 | | /// Required. |
| | | 63 | | /// </remarks> |
| | | 64 | | public virtual Person Person { get; set; } |
| | | 65 | | |
| | | 66 | | /// <inheritdoc /> |
| | | 67 | | public virtual ICollection<Artwork> Artwork { get; private set; } |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// Gets a collection containing the metadata sources for this person role. |
| | | 71 | | /// </summary> |
| | | 72 | | public virtual ICollection<MetadataProviderId> Sources { get; private set; } |
| | | 73 | | |
| | | 74 | | /// <inheritdoc /> |
| | | 75 | | public void OnSavingChanges() |
| | | 76 | | { |
| | 0 | 77 | | RowVersion++; |
| | 0 | 78 | | } |
| | | 79 | | } |
| | | 80 | | } |