Rating.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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)
  32. {
  33. throw new ArgumentNullException(nameof(_metadata0));
  34. }
  35. _metadata0.Ratings.Add(this);
  36. Init();
  37. }
  38. /// <summary>
  39. /// Static create function (for use in LINQ queries, etc.)
  40. /// </summary>
  41. /// <param name="value"></param>
  42. /// <param name="_metadata0"></param>
  43. public static Rating Create(double value, Metadata _metadata0)
  44. {
  45. return new Rating(value, _metadata0);
  46. }
  47. /*************************************************************************
  48. * Properties
  49. *************************************************************************/
  50. /// <summary>
  51. /// Backing field for Id.
  52. /// </summary>
  53. internal int _Id;
  54. /// <summary>
  55. /// When provided in a partial class, allows value of Id to be changed before setting.
  56. /// </summary>
  57. partial void SetId(int oldValue, ref int newValue);
  58. /// <summary>
  59. /// When provided in a partial class, allows value of Id to be changed before returning.
  60. /// </summary>
  61. partial void GetId(ref int result);
  62. /// <summary>
  63. /// Identity, Indexed, Required.
  64. /// </summary>
  65. [Key]
  66. [Required]
  67. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  68. public int Id
  69. {
  70. get
  71. {
  72. int value = _Id;
  73. GetId(ref value);
  74. return _Id = value;
  75. }
  76. protected set
  77. {
  78. int oldValue = _Id;
  79. SetId(oldValue, ref value);
  80. if (oldValue != value)
  81. {
  82. _Id = value;
  83. }
  84. }
  85. }
  86. /// <summary>
  87. /// Backing field for Value.
  88. /// </summary>
  89. protected double _Value;
  90. /// <summary>
  91. /// When provided in a partial class, allows value of Value to be changed before setting.
  92. /// </summary>
  93. partial void SetValue(double oldValue, ref double newValue);
  94. /// <summary>
  95. /// When provided in a partial class, allows value of Value to be changed before returning.
  96. /// </summary>
  97. partial void GetValue(ref double result);
  98. /// <summary>
  99. /// Required.
  100. /// </summary>
  101. [Required]
  102. public double Value
  103. {
  104. get
  105. {
  106. double value = _Value;
  107. GetValue(ref value);
  108. return _Value = value;
  109. }
  110. set
  111. {
  112. double oldValue = _Value;
  113. SetValue(oldValue, ref value);
  114. if (oldValue != value)
  115. {
  116. _Value = value;
  117. }
  118. }
  119. }
  120. /// <summary>
  121. /// Backing field for Votes.
  122. /// </summary>
  123. protected int? _Votes;
  124. /// <summary>
  125. /// When provided in a partial class, allows value of Votes to be changed before setting.
  126. /// </summary>
  127. partial void SetVotes(int? oldValue, ref int? newValue);
  128. /// <summary>
  129. /// When provided in a partial class, allows value of Votes to be changed before returning.
  130. /// </summary>
  131. partial void GetVotes(ref int? result);
  132. public int? Votes
  133. {
  134. get
  135. {
  136. int? value = _Votes;
  137. GetVotes(ref value);
  138. return _Votes = value;
  139. }
  140. set
  141. {
  142. int? oldValue = _Votes;
  143. SetVotes(oldValue, ref value);
  144. if (oldValue != value)
  145. {
  146. _Votes = value;
  147. }
  148. }
  149. }
  150. /// <summary>
  151. /// Required, ConcurrenyToken.
  152. /// </summary>
  153. [ConcurrencyCheck]
  154. [Required]
  155. public uint RowVersion { get; set; }
  156. public void OnSavingChanges()
  157. {
  158. RowVersion++;
  159. }
  160. /*************************************************************************
  161. * Navigation properties
  162. *************************************************************************/
  163. /// <summary>
  164. /// If this is NULL it&apos;s the internal user rating.
  165. /// </summary>
  166. [ForeignKey("RatingSource_RatingType_Id")]
  167. public virtual RatingSource RatingType { get; set; }
  168. }
  169. }