Permission.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #pragma warning disable CS1591
  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 partial 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. Init();
  24. }
  25. /// <summary>
  26. /// Initializes a new instance of the <see cref="Permission"/> class.
  27. /// Default constructor. Protected due to required properties, but present because EF needs it.
  28. /// </summary>
  29. protected Permission()
  30. {
  31. Init();
  32. }
  33. /*************************************************************************
  34. * Properties
  35. *************************************************************************/
  36. /// <summary>
  37. /// Gets or sets the id of this permission.
  38. /// </summary>
  39. /// <remarks>
  40. /// Identity, Indexed, Required.
  41. /// </remarks>
  42. [Key]
  43. [Required]
  44. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  45. public int Id { get; protected set; }
  46. /// <summary>
  47. /// Gets or sets the type of this permission.
  48. /// </summary>
  49. /// <remarks>
  50. /// Required.
  51. /// </remarks>
  52. [Required]
  53. public PermissionKind Kind { get; protected set; }
  54. /// <summary>
  55. /// Gets or sets a value indicating whether the associated user has this permission.
  56. /// </summary>
  57. /// <remarks>
  58. /// Required.
  59. /// </remarks>
  60. [Required]
  61. public bool Value { get; set; }
  62. /// <summary>
  63. /// Gets or sets the row version.
  64. /// </summary>
  65. /// <remarks>
  66. /// Required, ConcurrencyToken.
  67. /// </remarks>
  68. [ConcurrencyCheck]
  69. [Required]
  70. public uint RowVersion { get; set; }
  71. /// <summary>
  72. /// Static create function (for use in LINQ queries, etc.)
  73. /// </summary>
  74. /// <param name="kind">The permission kind.</param>
  75. /// <param name="value">The value of this permission.</param>
  76. /// <returns>The newly created instance.</returns>
  77. public static Permission Create(PermissionKind kind, bool value)
  78. {
  79. return new Permission(kind, value);
  80. }
  81. /// <inheritdoc/>
  82. public void OnSavingChanges()
  83. {
  84. RowVersion++;
  85. }
  86. partial void Init();
  87. }
  88. }