Permission.cs 2.0 KB

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