2019-06-01 13:40:01 -07:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2020-05-15 14:24:01 -07:00
|
|
|
using Jellyfin.Data.Enums;
|
2020-08-30 15:50:54 -07:00
|
|
|
using Jellyfin.Data.Interfaces;
|
2019-06-01 13:40:01 -07:00
|
|
|
|
|
|
|
namespace Jellyfin.Data.Entities
|
|
|
|
{
|
2020-05-22 17:20:18 -07:00
|
|
|
/// <summary>
|
|
|
|
/// An entity representing whether the associated user has a specific permission.
|
|
|
|
/// </summary>
|
2020-09-01 08:04:32 -07:00
|
|
|
public class Permission : IHasConcurrencyToken
|
2020-05-02 14:56:05 -07:00
|
|
|
{
|
|
|
|
/// <summary>
|
2020-05-19 19:12:03 -07:00
|
|
|
/// Initializes a new instance of the <see cref="Permission"/> class.
|
2020-05-22 17:20:18 -07:00
|
|
|
/// Public constructor with required data.
|
2020-05-02 14:56:05 -07:00
|
|
|
/// </summary>
|
2020-05-22 17:20:18 -07:00
|
|
|
/// <param name="kind">The permission kind.</param>
|
|
|
|
/// <param name="value">The value of this permission.</param>
|
2020-05-15 14:24:01 -07:00
|
|
|
public Permission(PermissionKind kind, bool value)
|
2020-05-02 14:56:05 -07:00
|
|
|
{
|
2020-05-15 14:24:01 -07:00
|
|
|
Kind = kind;
|
|
|
|
Value = value;
|
2020-05-02 14:56:05 -07:00
|
|
|
}
|
|
|
|
|
2020-05-19 19:12:03 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="Permission"/> class.
|
|
|
|
/// Default constructor. Protected due to required properties, but present because EF needs it.
|
|
|
|
/// </summary>
|
|
|
|
protected Permission()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-05-02 14:56:05 -07:00
|
|
|
/// <summary>
|
2020-05-22 17:20:18 -07:00
|
|
|
/// Gets or sets the id of this permission.
|
2020-05-02 14:56:05 -07:00
|
|
|
/// </summary>
|
2020-05-22 17:20:18 -07:00
|
|
|
/// <remarks>
|
|
|
|
/// Identity, Indexed, Required.
|
|
|
|
/// </remarks>
|
2020-05-02 14:56:05 -07:00
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
|
|
public int Id { get; protected set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-22 17:20:18 -07:00
|
|
|
/// Gets or sets the type of this permission.
|
2020-05-02 14:56:05 -07:00
|
|
|
/// </summary>
|
2020-05-22 17:20:18 -07:00
|
|
|
/// <remarks>
|
|
|
|
/// Required.
|
|
|
|
/// </remarks>
|
|
|
|
public PermissionKind Kind { get; protected set; }
|
2020-05-02 14:56:05 -07:00
|
|
|
|
|
|
|
/// <summary>
|
2020-05-22 17:20:18 -07:00
|
|
|
/// Gets or sets a value indicating whether the associated user has this permission.
|
2020-05-02 14:56:05 -07:00
|
|
|
/// </summary>
|
2020-05-22 17:20:18 -07:00
|
|
|
/// <remarks>
|
|
|
|
/// Required.
|
|
|
|
/// </remarks>
|
2020-05-02 14:56:05 -07:00
|
|
|
public bool Value { get; set; }
|
|
|
|
|
2020-09-01 08:04:32 -07:00
|
|
|
/// <inheritdoc />
|
2020-05-02 14:56:05 -07:00
|
|
|
[ConcurrencyCheck]
|
|
|
|
public uint RowVersion { get; set; }
|
|
|
|
|
2020-05-22 17:20:18 -07:00
|
|
|
/// <inheritdoc/>
|
|
|
|
public void OnSavingChanges()
|
2020-05-02 14:56:05 -07:00
|
|
|
{
|
2020-05-22 17:20:18 -07:00
|
|
|
RowVersion++;
|
2020-05-02 14:56:05 -07:00
|
|
|
}
|
|
|
|
}
|
2019-06-01 13:40:01 -07:00
|
|
|
}
|