aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Data/Entities/Preference.cs
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-06-13 15:20:13 -0600
committercrobibero <cody@robibe.ro>2020-06-13 15:20:13 -0600
commitbcce8190ffe6cf2b4926c64bca98b8266c0937b0 (patch)
tree7008786b1e0631445437f451cc6422b4be9a5f0d /Jellyfin.Data/Entities/Preference.cs
parent88b6c26472ad57822d3ab79a043db259ffcbb0e3 (diff)
parent0011e8df47380936742302ef40639a4626a780ed (diff)
Merge remote-tracking branch 'upstream/api-migration' into api-channel
Diffstat (limited to 'Jellyfin.Data/Entities/Preference.cs')
-rw-r--r--Jellyfin.Data/Entities/Preference.cs107
1 files changed, 107 insertions, 0 deletions
diff --git a/Jellyfin.Data/Entities/Preference.cs b/Jellyfin.Data/Entities/Preference.cs
new file mode 100644
index 000000000..505f52e6b
--- /dev/null
+++ b/Jellyfin.Data/Entities/Preference.cs
@@ -0,0 +1,107 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace Jellyfin.Data.Entities
+{
+ public partial class Preference
+ {
+ partial void Init();
+
+ /// <summary>
+ /// Default constructor. Protected due to required properties, but present because EF needs it.
+ /// </summary>
+ protected Preference()
+ {
+ Init();
+ }
+
+ /// <summary>
+ /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
+ /// </summary>
+ public static Preference CreatePreferenceUnsafe()
+ {
+ return new Preference();
+ }
+
+ /// <summary>
+ /// Public constructor with required data
+ /// </summary>
+ /// <param name="kind"></param>
+ /// <param name="value"></param>
+ /// <param name="_user0"></param>
+ /// <param name="_group1"></param>
+ public Preference(Enums.PreferenceKind kind, string value, User _user0, Group _group1)
+ {
+ this.Kind = kind;
+
+ if (string.IsNullOrEmpty(value)) throw new ArgumentNullException(nameof(value));
+ this.Value = value;
+
+ if (_user0 == null) throw new ArgumentNullException(nameof(_user0));
+ _user0.Preferences.Add(this);
+
+ if (_group1 == null) throw new ArgumentNullException(nameof(_group1));
+ _group1.Preferences.Add(this);
+
+
+ Init();
+ }
+
+ /// <summary>
+ /// Static create function (for use in LINQ queries, etc.)
+ /// </summary>
+ /// <param name="kind"></param>
+ /// <param name="value"></param>
+ /// <param name="_user0"></param>
+ /// <param name="_group1"></param>
+ public static Preference Create(Enums.PreferenceKind kind, string value, User _user0, Group _group1)
+ {
+ return new Preference(kind, value, _user0, _group1);
+ }
+
+ /*************************************************************************
+ * Properties
+ *************************************************************************/
+
+ /// <summary>
+ /// Identity, Indexed, Required
+ /// </summary>
+ [Key]
+ [Required]
+ [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int Id { get; protected set; }
+
+ /// <summary>
+ /// Required
+ /// </summary>
+ [Required]
+ public Enums.PreferenceKind Kind { get; set; }
+
+ /// <summary>
+ /// Required, Max length = 65535
+ /// </summary>
+ [Required]
+ [MaxLength(65535)]
+ [StringLength(65535)]
+ public string Value { get; set; }
+
+ /// <summary>
+ /// Required, ConcurrenyToken
+ /// </summary>
+ [ConcurrencyCheck]
+ [Required]
+ public uint RowVersion { get; set; }
+
+ public void OnSavingChanges()
+ {
+ RowVersion++;
+ }
+
+ /*************************************************************************
+ * Navigation properties
+ *************************************************************************/
+
+ }
+}
+