RatingSource.cs 7.0 KB

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