RatingSource.cs 7.0 KB

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