jellyfin/Jellyfin.Data/Entities/Permission.cs

69 lines
2 KiB
C#
Raw Normal View History

2021-03-09 05:57:38 +01:00
#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
2020-05-15 23:24:01 +02:00
using Jellyfin.Data.Enums;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities
{
2020-05-23 02:20:18 +02:00
/// <summary>
/// An entity representing whether the associated user has a specific permission.
/// </summary>
2020-09-01 17:04:32 +02:00
public class Permission : IHasConcurrencyToken
2020-05-02 23:56:05 +02:00
{
/// <summary>
/// Initializes a new instance of the <see cref="Permission"/> class.
2020-05-23 02:20:18 +02:00
/// Public constructor with required data.
2020-05-02 23:56:05 +02:00
/// </summary>
2020-05-23 02:20:18 +02:00
/// <param name="kind">The permission kind.</param>
/// <param name="value">The value of this permission.</param>
2020-05-15 23:24:01 +02:00
public Permission(PermissionKind kind, bool value)
2020-05-02 23:56:05 +02:00
{
2020-05-15 23:24:01 +02:00
Kind = kind;
Value = value;
2020-05-02 23:56:05 +02:00
}
/// <summary>
2021-03-18 00:08:11 +01:00
/// Gets the id of this permission.
2020-05-02 23:56:05 +02:00
/// </summary>
2020-05-23 02:20:18 +02:00
/// <remarks>
/// Identity, Indexed, Required.
/// </remarks>
2020-05-02 23:56:05 +02:00
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
2021-03-18 00:08:11 +01:00
public int Id { get; private set; }
2020-05-02 23:56:05 +02:00
/// <summary>
/// Gets or sets the id of the associated user.
/// </summary>
2021-03-19 05:26:07 +01:00
public Guid? UserId { get; set; }
2020-05-02 23:56:05 +02:00
/// <summary>
2021-03-18 00:08:11 +01:00
/// Gets the type of this permission.
2020-05-02 23:56:05 +02:00
/// </summary>
2020-05-23 02:20:18 +02:00
/// <remarks>
/// Required.
/// </remarks>
2021-03-18 00:08:11 +01:00
public PermissionKind Kind { get; private set; }
2020-05-02 23:56:05 +02:00
/// <summary>
2020-05-23 02:20:18 +02:00
/// Gets or sets a value indicating whether the associated user has this permission.
2020-05-02 23:56:05 +02:00
/// </summary>
2020-05-23 02:20:18 +02:00
/// <remarks>
/// Required.
/// </remarks>
2020-05-02 23:56:05 +02:00
public bool Value { get; set; }
2020-09-01 17:04:32 +02:00
/// <inheritdoc />
2020-05-02 23:56:05 +02:00
[ConcurrencyCheck]
2021-03-18 00:08:11 +01:00
public uint RowVersion { get; private set; }
2020-05-02 23:56:05 +02:00
2020-05-23 02:20:18 +02:00
/// <inheritdoc/>
public void OnSavingChanges()
2020-05-02 23:56:05 +02:00
{
2020-05-23 02:20:18 +02:00
RowVersion++;
2020-05-02 23:56:05 +02:00
}
}
}