2
0

RatingSource.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Jellyfin.Data.Interfaces;
  5. namespace Jellyfin.Data.Entities.Libraries
  6. {
  7. /// <summary>
  8. /// This is the entity to store review ratings, not age ratings.
  9. /// </summary>
  10. public class RatingSource : IHasConcurrencyToken
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="RatingSource"/> class.
  14. /// </summary>
  15. /// <param name="minimumValue">The minimum value.</param>
  16. /// <param name="maximumValue">The maximum value.</param>
  17. /// <param name="rating">The rating.</param>
  18. public RatingSource(double minimumValue, double maximumValue, Rating rating)
  19. {
  20. MinimumValue = minimumValue;
  21. MaximumValue = maximumValue;
  22. if (rating == null)
  23. {
  24. throw new ArgumentNullException(nameof(rating));
  25. }
  26. rating.RatingType = this;
  27. }
  28. /// <summary>
  29. /// Initializes a new instance of the <see cref="RatingSource"/> class.
  30. /// </summary>
  31. /// <remarks>
  32. /// Default constructor. Protected due to required properties, but present because EF needs it.
  33. /// </remarks>
  34. protected RatingSource()
  35. {
  36. }
  37. /// <summary>
  38. /// Gets or sets the id.
  39. /// </summary>
  40. /// <remarks>
  41. /// Identity, Indexed, Required.
  42. /// </remarks>
  43. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  44. public int Id { get; protected set; }
  45. /// <summary>
  46. /// Gets or sets the name.
  47. /// </summary>
  48. /// <remarks>
  49. /// Max length = 1024.
  50. /// </remarks>
  51. [MaxLength(1024)]
  52. [StringLength(1024)]
  53. public string Name { get; set; }
  54. /// <summary>
  55. /// Gets or sets the minimum value.
  56. /// </summary>
  57. /// <remarks>
  58. /// Required.
  59. /// </remarks>
  60. public double MinimumValue { get; set; }
  61. /// <summary>
  62. /// Gets or sets the maximum value.
  63. /// </summary>
  64. /// <remarks>
  65. /// Required.
  66. /// </remarks>
  67. public double MaximumValue { get; set; }
  68. /// <inheritdoc />
  69. [ConcurrencyCheck]
  70. public uint RowVersion { get; set; }
  71. /// <summary>
  72. /// Gets or sets the metadata source.
  73. /// </summary>
  74. public virtual MetadataProviderId Source { get; set; }
  75. /// <inheritdoc />
  76. public void OnSavingChanges()
  77. {
  78. RowVersion++;
  79. }
  80. }
  81. }