| | | 1 | | using System; |
| | | 2 | | using System.ComponentModel.DataAnnotations; |
| | | 3 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 4 | | using Jellyfin.Database.Implementations.Enums; |
| | | 5 | | using Jellyfin.Database.Implementations.Interfaces; |
| | | 6 | | |
| | | 7 | | namespace Jellyfin.Database.Implementations.Entities |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// An entity representing a preference attached to a user or group. |
| | | 11 | | /// </summary> |
| | | 12 | | public class Preference : IHasConcurrencyToken |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Initializes a new instance of the <see cref="Preference"/> class. |
| | | 16 | | /// Public constructor with required data. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="kind">The preference kind.</param> |
| | | 19 | | /// <param name="value">The value.</param> |
| | | 20 | | public Preference(PreferenceKind kind, string value) |
| | | 21 | | { |
| | 494 | 22 | | Kind = kind; |
| | 494 | 23 | | Value = value ?? throw new ArgumentNullException(nameof(value)); |
| | 494 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Gets the id of this preference. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <remarks> |
| | | 30 | | /// Identity, Indexed, Required. |
| | | 31 | | /// </remarks> |
| | | 32 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | | 33 | | public int Id { get; private set; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Gets or sets the id of the associated user. |
| | | 37 | | /// </summary> |
| | | 38 | | public Guid? UserId { get; set; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Gets the type of this preference. |
| | | 42 | | /// </summary> |
| | | 43 | | /// <remarks> |
| | | 44 | | /// Required. |
| | | 45 | | /// </remarks> |
| | | 46 | | public PreferenceKind Kind { get; private set; } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// Gets or sets the value of this preference. |
| | | 50 | | /// </summary> |
| | | 51 | | /// <remarks> |
| | | 52 | | /// Required, Max length = 65535. |
| | | 53 | | /// </remarks> |
| | | 54 | | [MaxLength(65535)] |
| | | 55 | | [StringLength(65535)] |
| | | 56 | | public string Value { get; set; } |
| | | 57 | | |
| | | 58 | | /// <inheritdoc/> |
| | | 59 | | [ConcurrencyCheck] |
| | | 60 | | public uint RowVersion { get; private set; } |
| | | 61 | | |
| | | 62 | | /// <inheritdoc/> |
| | | 63 | | public void OnSavingChanges() |
| | | 64 | | { |
| | 0 | 65 | | RowVersion++; |
| | 0 | 66 | | } |
| | | 67 | | } |
| | | 68 | | } |