2019-06-01 20:40:01 +00:00
|
|
|
using System;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2020-05-15 21:24:01 +00:00
|
|
|
using Jellyfin.Data.Enums;
|
2020-08-30 22:50:54 +00:00
|
|
|
using Jellyfin.Data.Interfaces;
|
2019-06-01 20:40:01 +00:00
|
|
|
|
|
|
|
namespace Jellyfin.Data.Entities
|
|
|
|
{
|
2020-05-15 21:24:01 +00:00
|
|
|
/// <summary>
|
|
|
|
/// An entity representing a preference attached to a user or group.
|
|
|
|
/// </summary>
|
2020-08-30 22:50:54 +00:00
|
|
|
public class Preference : IHasConcurrencyToken
|
2020-05-02 21:56:05 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
2020-05-15 21:24:01 +00:00
|
|
|
/// Initializes a new instance of the <see cref="Preference"/> class.
|
|
|
|
/// Public constructor with required data.
|
2020-05-02 21:56:05 +00:00
|
|
|
/// </summary>
|
2020-05-15 21:24:01 +00:00
|
|
|
/// <param name="kind">The preference kind.</param>
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
public Preference(PreferenceKind kind, string value)
|
2020-05-02 21:56:05 +00:00
|
|
|
{
|
2020-05-15 21:24:01 +00:00
|
|
|
Kind = kind;
|
|
|
|
Value = value ?? throw new ArgumentNullException(nameof(value));
|
2020-05-02 21:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-15 21:24:01 +00:00
|
|
|
/// Initializes a new instance of the <see cref="Preference"/> class.
|
|
|
|
/// Default constructor. Protected due to required properties, but present because EF needs it.
|
2020-05-02 21:56:05 +00:00
|
|
|
/// </summary>
|
2020-05-15 21:24:01 +00:00
|
|
|
protected Preference()
|
2020-05-02 21:56:05 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-19 23:44:55 +00:00
|
|
|
/// Gets or sets the id of this preference.
|
2020-05-02 21:56:05 +00:00
|
|
|
/// </summary>
|
2020-05-19 23:44:55 +00:00
|
|
|
/// <remarks>
|
|
|
|
/// Identity, Indexed, Required.
|
|
|
|
/// </remarks>
|
2020-05-02 21:56:05 +00:00
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
|
|
public int Id { get; protected set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-19 23:44:55 +00:00
|
|
|
/// Gets or sets the type of this preference.
|
2020-05-02 21:56:05 +00:00
|
|
|
/// </summary>
|
2020-05-19 23:44:55 +00:00
|
|
|
/// <remarks>
|
|
|
|
/// Required.
|
|
|
|
/// </remarks>
|
|
|
|
public PreferenceKind Kind { get; protected set; }
|
2020-05-02 21:56:05 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2020-05-19 23:44:55 +00:00
|
|
|
/// Gets or sets the value of this preference.
|
2020-05-02 21:56:05 +00:00
|
|
|
/// </summary>
|
2020-05-19 23:44:55 +00:00
|
|
|
/// <remarks>
|
|
|
|
/// Required, Max length = 65535.
|
|
|
|
/// </remarks>
|
2020-05-02 21:56:05 +00:00
|
|
|
[Required]
|
|
|
|
[MaxLength(65535)]
|
|
|
|
[StringLength(65535)]
|
|
|
|
public string Value { get; set; }
|
|
|
|
|
2020-09-01 15:05:21 +00:00
|
|
|
/// <inheritdoc/>
|
2020-05-02 21:56:05 +00:00
|
|
|
[ConcurrencyCheck]
|
|
|
|
public uint RowVersion { get; set; }
|
|
|
|
|
2020-05-15 21:24:01 +00:00
|
|
|
/// <inheritdoc/>
|
2020-05-02 21:56:05 +00:00
|
|
|
public void OnSavingChanges()
|
|
|
|
{
|
|
|
|
RowVersion++;
|
|
|
|
}
|
|
|
|
}
|
2019-06-01 20:40:01 +00:00
|
|
|
}
|