jellyfin-server/Jellyfin.Data/Entities/Preference.cs

64 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
2020-05-15 21:24:01 +00:00
using Jellyfin.Data.Enums;
using Jellyfin.Data.Interfaces;
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>
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-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
[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++;
}
}
}