using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Enums;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities
{
    /// 
    /// An entity representing whether the associated user has a specific permission.
    /// 
    public class Permission : IHasConcurrencyToken
    {
        /// 
        /// Initializes a new instance of the  class.
        /// Public constructor with required data.
        /// 
        /// The permission kind.
        /// The value of this permission.
        public Permission(PermissionKind kind, bool value)
        {
            Kind = kind;
            Value = value;
        }
        /// 
        /// Initializes a new instance of the  class.
        /// Default constructor. Protected due to required properties, but present because EF needs it.
        /// 
        protected Permission()
        {
        }
        /// 
        /// Gets or sets the id of this permission.
        /// 
        /// 
        /// Identity, Indexed, Required.
        /// 
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; protected set; }
        /// 
        /// Gets or sets the type of this permission.
        /// 
        /// 
        /// Required.
        /// 
        public PermissionKind Kind { get; protected set; }
        /// 
        /// Gets or sets a value indicating whether the associated user has this permission.
        /// 
        /// 
        /// Required.
        /// 
        public bool Value { get; set; }
        /// 
        [ConcurrencyCheck]
        public uint RowVersion { get; set; }
        /// 
        public void OnSavingChanges()
        {
            RowVersion++;
        }
    }
}