2
0

Permission.cs 2.0 KB

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