Permission.cs 2.1 KB

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