Rating.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. namespace Jellyfin.Data.Entities
  5. {
  6. public partial class Rating
  7. {
  8. partial void Init();
  9. /// <summary>
  10. /// Default constructor. Protected due to required properties, but present because EF needs it.
  11. /// </summary>
  12. protected Rating()
  13. {
  14. Init();
  15. }
  16. /// <summary>
  17. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  18. /// </summary>
  19. public static Rating CreateRatingUnsafe()
  20. {
  21. return new Rating();
  22. }
  23. /// <summary>
  24. /// Public constructor with required data
  25. /// </summary>
  26. /// <param name="value"></param>
  27. /// <param name="_metadata0"></param>
  28. public Rating(double value, Metadata _metadata0)
  29. {
  30. this.Value = value;
  31. if (_metadata0 == null) throw new ArgumentNullException(nameof(_metadata0));
  32. _metadata0.Ratings.Add(this);
  33. Init();
  34. }
  35. /// <summary>
  36. /// Static create function (for use in LINQ queries, etc.)
  37. /// </summary>
  38. /// <param name="value"></param>
  39. /// <param name="_metadata0"></param>
  40. public static Rating Create(double value, Metadata _metadata0)
  41. {
  42. return new Rating(value, _metadata0);
  43. }
  44. /*************************************************************************
  45. * Properties
  46. *************************************************************************/
  47. /// <summary>
  48. /// Backing field for Id
  49. /// </summary>
  50. internal int _Id;
  51. /// <summary>
  52. /// When provided in a partial class, allows value of Id to be changed before setting.
  53. /// </summary>
  54. partial void SetId(int oldValue, ref int newValue);
  55. /// <summary>
  56. /// When provided in a partial class, allows value of Id to be changed before returning.
  57. /// </summary>
  58. partial void GetId(ref int result);
  59. /// <summary>
  60. /// Identity, Indexed, Required
  61. /// </summary>
  62. [Key]
  63. [Required]
  64. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  65. public int Id
  66. {
  67. get
  68. {
  69. int value = _Id;
  70. GetId(ref value);
  71. return (_Id = value);
  72. }
  73. protected set
  74. {
  75. int oldValue = _Id;
  76. SetId(oldValue, ref value);
  77. if (oldValue != value)
  78. {
  79. _Id = value;
  80. }
  81. }
  82. }
  83. /// <summary>
  84. /// Backing field for Value
  85. /// </summary>
  86. protected double _Value;
  87. /// <summary>
  88. /// When provided in a partial class, allows value of Value to be changed before setting.
  89. /// </summary>
  90. partial void SetValue(double oldValue, ref double newValue);
  91. /// <summary>
  92. /// When provided in a partial class, allows value of Value to be changed before returning.
  93. /// </summary>
  94. partial void GetValue(ref double result);
  95. /// <summary>
  96. /// Required
  97. /// </summary>
  98. [Required]
  99. public double Value
  100. {
  101. get
  102. {
  103. double value = _Value;
  104. GetValue(ref value);
  105. return (_Value = value);
  106. }
  107. set
  108. {
  109. double oldValue = _Value;
  110. SetValue(oldValue, ref value);
  111. if (oldValue != value)
  112. {
  113. _Value = value;
  114. }
  115. }
  116. }
  117. /// <summary>
  118. /// Backing field for Votes
  119. /// </summary>
  120. protected int? _Votes;
  121. /// <summary>
  122. /// When provided in a partial class, allows value of Votes to be changed before setting.
  123. /// </summary>
  124. partial void SetVotes(int? oldValue, ref int? newValue);
  125. /// <summary>
  126. /// When provided in a partial class, allows value of Votes to be changed before returning.
  127. /// </summary>
  128. partial void GetVotes(ref int? result);
  129. public int? Votes
  130. {
  131. get
  132. {
  133. int? value = _Votes;
  134. GetVotes(ref value);
  135. return (_Votes = value);
  136. }
  137. set
  138. {
  139. int? oldValue = _Votes;
  140. SetVotes(oldValue, ref value);
  141. if (oldValue != value)
  142. {
  143. _Votes = value;
  144. }
  145. }
  146. }
  147. /// <summary>
  148. /// Required, ConcurrenyToken
  149. /// </summary>
  150. [ConcurrencyCheck]
  151. [Required]
  152. public uint RowVersion { get; set; }
  153. public void OnSavingChanges()
  154. {
  155. RowVersion++;
  156. }
  157. /*************************************************************************
  158. * Navigation properties
  159. *************************************************************************/
  160. /// <summary>
  161. /// If this is NULL it&apos;s the internal user rating.
  162. /// </summary>
  163. [ForeignKey("RatingSource_RatingType_Id")]
  164. public virtual RatingSource RatingType { get; set; }
  165. }
  166. }