| | | 1 | | #pragma warning disable CA1711 // Identifiers should not have incorrect suffix |
| | | 2 | | |
| | | 3 | | using System; |
| | | 4 | | using System.ComponentModel.DataAnnotations; |
| | | 5 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 6 | | using Jellyfin.Database.Implementations.Enums; |
| | | 7 | | using Jellyfin.Database.Implementations.Interfaces; |
| | | 8 | | |
| | | 9 | | namespace Jellyfin.Database.Implementations.Entities |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// An entity representing whether the associated user has a specific permission. |
| | | 13 | | /// </summary> |
| | | 14 | | public class Permission : IHasConcurrencyToken |
| | | 15 | | { |
| | | 16 | | /// <summary> |
| | | 17 | | /// Initializes a new instance of the <see cref="Permission"/> class. |
| | | 18 | | /// Public constructor with required data. |
| | | 19 | | /// </summary> |
| | | 20 | | /// <param name="kind">The permission kind.</param> |
| | | 21 | | /// <param name="value">The value of this permission.</param> |
| | | 22 | | public Permission(PermissionKind kind, bool value) |
| | | 23 | | { |
| | 912 | 24 | | Kind = kind; |
| | 912 | 25 | | Value = value; |
| | 912 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets the id of this permission. |
| | | 30 | | /// </summary> |
| | | 31 | | /// <remarks> |
| | | 32 | | /// Identity, Indexed, Required. |
| | | 33 | | /// </remarks> |
| | | 34 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | | 35 | | public int Id { get; private set; } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Gets or sets the id of the associated user. |
| | | 39 | | /// </summary> |
| | | 40 | | public Guid? UserId { get; set; } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Gets the type of this permission. |
| | | 44 | | /// </summary> |
| | | 45 | | /// <remarks> |
| | | 46 | | /// Required. |
| | | 47 | | /// </remarks> |
| | | 48 | | public PermissionKind Kind { get; private set; } |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Gets or sets a value indicating whether the associated user has this permission. |
| | | 52 | | /// </summary> |
| | | 53 | | /// <remarks> |
| | | 54 | | /// Required. |
| | | 55 | | /// </remarks> |
| | | 56 | | public bool Value { get; set; } |
| | | 57 | | |
| | | 58 | | /// <inheritdoc /> |
| | | 59 | | [ConcurrencyCheck] |
| | | 60 | | public uint RowVersion { get; private set; } |
| | | 61 | | |
| | | 62 | | /// <inheritdoc/> |
| | | 63 | | public void OnSavingChanges() |
| | | 64 | | { |
| | 0 | 65 | | RowVersion++; |
| | 0 | 66 | | } |
| | | 67 | | } |
| | | 68 | | } |