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