Rating.cs 5.5 KB

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