RatingSource.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. /// <summary>
  8. /// This is the entity to store review ratings, not age ratings.
  9. /// </summary>
  10. public partial class RatingSource
  11. {
  12. partial void Init();
  13. /// <summary>
  14. /// Default constructor. Protected due to required properties, but present because EF needs it.
  15. /// </summary>
  16. protected RatingSource()
  17. {
  18. Init();
  19. }
  20. /// <summary>
  21. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  22. /// </summary>
  23. public static RatingSource CreateRatingSourceUnsafe()
  24. {
  25. return new RatingSource();
  26. }
  27. /// <summary>
  28. /// Public constructor with required data.
  29. /// </summary>
  30. /// <param name="maximumvalue"></param>
  31. /// <param name="minimumvalue"></param>
  32. /// <param name="_rating0"></param>
  33. public RatingSource(double maximumvalue, double minimumvalue, Rating _rating0)
  34. {
  35. this.MaximumValue = maximumvalue;
  36. this.MinimumValue = minimumvalue;
  37. if (_rating0 == null)
  38. {
  39. throw new ArgumentNullException(nameof(_rating0));
  40. }
  41. _rating0.RatingType = this;
  42. Init();
  43. }
  44. /// <summary>
  45. /// Static create function (for use in LINQ queries, etc.)
  46. /// </summary>
  47. /// <param name="maximumvalue"></param>
  48. /// <param name="minimumvalue"></param>
  49. /// <param name="_rating0"></param>
  50. public static RatingSource Create(double maximumvalue, double minimumvalue, Rating _rating0)
  51. {
  52. return new RatingSource(maximumvalue, minimumvalue, _rating0);
  53. }
  54. /*************************************************************************
  55. * Properties
  56. *************************************************************************/
  57. /// <summary>
  58. /// Backing field for Id.
  59. /// </summary>
  60. internal int _Id;
  61. /// <summary>
  62. /// When provided in a partial class, allows value of Id to be changed before setting.
  63. /// </summary>
  64. partial void SetId(int oldValue, ref int newValue);
  65. /// <summary>
  66. /// When provided in a partial class, allows value of Id to be changed before returning.
  67. /// </summary>
  68. partial void GetId(ref int result);
  69. /// <summary>
  70. /// Identity, Indexed, Required.
  71. /// </summary>
  72. [Key]
  73. [Required]
  74. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  75. public int Id
  76. {
  77. get
  78. {
  79. int value = _Id;
  80. GetId(ref value);
  81. return _Id = value;
  82. }
  83. protected set
  84. {
  85. int oldValue = _Id;
  86. SetId(oldValue, ref value);
  87. if (oldValue != value)
  88. {
  89. _Id = value;
  90. }
  91. }
  92. }
  93. /// <summary>
  94. /// Backing field for Name.
  95. /// </summary>
  96. protected string _Name;
  97. /// <summary>
  98. /// When provided in a partial class, allows value of Name to be changed before setting.
  99. /// </summary>
  100. partial void SetName(string oldValue, ref string newValue);
  101. /// <summary>
  102. /// When provided in a partial class, allows value of Name to be changed before returning.
  103. /// </summary>
  104. partial void GetName(ref string result);
  105. /// <summary>
  106. /// Max length = 1024
  107. /// </summary>
  108. [MaxLength(1024)]
  109. [StringLength(1024)]
  110. public string Name
  111. {
  112. get
  113. {
  114. string value = _Name;
  115. GetName(ref value);
  116. return _Name = value;
  117. }
  118. set
  119. {
  120. string oldValue = _Name;
  121. SetName(oldValue, ref value);
  122. if (oldValue != value)
  123. {
  124. _Name = value;
  125. }
  126. }
  127. }
  128. /// <summary>
  129. /// Backing field for MaximumValue.
  130. /// </summary>
  131. protected double _MaximumValue;
  132. /// <summary>
  133. /// When provided in a partial class, allows value of MaximumValue to be changed before setting.
  134. /// </summary>
  135. partial void SetMaximumValue(double oldValue, ref double newValue);
  136. /// <summary>
  137. /// When provided in a partial class, allows value of MaximumValue to be changed before returning.
  138. /// </summary>
  139. partial void GetMaximumValue(ref double result);
  140. /// <summary>
  141. /// Required.
  142. /// </summary>
  143. [Required]
  144. public double MaximumValue
  145. {
  146. get
  147. {
  148. double value = _MaximumValue;
  149. GetMaximumValue(ref value);
  150. return _MaximumValue = value;
  151. }
  152. set
  153. {
  154. double oldValue = _MaximumValue;
  155. SetMaximumValue(oldValue, ref value);
  156. if (oldValue != value)
  157. {
  158. _MaximumValue = value;
  159. }
  160. }
  161. }
  162. /// <summary>
  163. /// Backing field for MinimumValue.
  164. /// </summary>
  165. protected double _MinimumValue;
  166. /// <summary>
  167. /// When provided in a partial class, allows value of MinimumValue to be changed before setting.
  168. /// </summary>
  169. partial void SetMinimumValue(double oldValue, ref double newValue);
  170. /// <summary>
  171. /// When provided in a partial class, allows value of MinimumValue to be changed before returning.
  172. /// </summary>
  173. partial void GetMinimumValue(ref double result);
  174. /// <summary>
  175. /// Required.
  176. /// </summary>
  177. [Required]
  178. public double MinimumValue
  179. {
  180. get
  181. {
  182. double value = _MinimumValue;
  183. GetMinimumValue(ref value);
  184. return _MinimumValue = value;
  185. }
  186. set
  187. {
  188. double oldValue = _MinimumValue;
  189. SetMinimumValue(oldValue, ref value);
  190. if (oldValue != value)
  191. {
  192. _MinimumValue = value;
  193. }
  194. }
  195. }
  196. /// <summary>
  197. /// Required, ConcurrenyToken.
  198. /// </summary>
  199. [ConcurrencyCheck]
  200. [Required]
  201. public uint RowVersion { get; set; }
  202. public void OnSavingChanges()
  203. {
  204. RowVersion++;
  205. }
  206. /*************************************************************************
  207. * Navigation properties
  208. *************************************************************************/
  209. [ForeignKey("MetadataProviderId_Source_Id")]
  210. public virtual MetadataProviderId Source { get; set; }
  211. }
  212. }