Permission.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. /// Gets or sets the id of this permission.
  26. /// </summary>
  27. /// <remarks>
  28. /// Identity, Indexed, Required.
  29. /// </remarks>
  30. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  31. public int Id { get; protected set; }
  32. /// <summary>
  33. /// Gets or sets the type of this permission.
  34. /// </summary>
  35. /// <remarks>
  36. /// Required.
  37. /// </remarks>
  38. public PermissionKind Kind { get; protected set; }
  39. /// <summary>
  40. /// Gets or sets a value indicating whether the associated user has this permission.
  41. /// </summary>
  42. /// <remarks>
  43. /// Required.
  44. /// </remarks>
  45. public bool Value { get; set; }
  46. /// <inheritdoc />
  47. [ConcurrencyCheck]
  48. public uint RowVersion { get; set; }
  49. /// <inheritdoc/>
  50. public void OnSavingChanges()
  51. {
  52. RowVersion++;
  53. }
  54. }
  55. }