Rating.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.ComponentModel.DataAnnotations;
  2. using System.ComponentModel.DataAnnotations.Schema;
  3. using Jellyfin.Data.Interfaces;
  4. namespace Jellyfin.Data.Entities.Libraries
  5. {
  6. /// <summary>
  7. /// An entity representing a rating for an entity.
  8. /// </summary>
  9. public class Rating : IHasConcurrencyToken
  10. {
  11. /// <summary>
  12. /// Initializes a new instance of the <see cref="Rating"/> class.
  13. /// </summary>
  14. /// <param name="value">The value.</param>
  15. public Rating(double value)
  16. {
  17. Value = value;
  18. }
  19. /// <summary>
  20. /// Gets the id.
  21. /// </summary>
  22. /// <remarks>
  23. /// Identity, Indexed, Required.
  24. /// </remarks>
  25. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  26. public int Id { get; private set; }
  27. /// <summary>
  28. /// Gets or sets the value.
  29. /// </summary>
  30. /// <remarks>
  31. /// Required.
  32. /// </remarks>
  33. public double Value { get; set; }
  34. /// <summary>
  35. /// Gets or sets the number of votes.
  36. /// </summary>
  37. public int? Votes { get; set; }
  38. /// <inheritdoc />
  39. [ConcurrencyCheck]
  40. public uint RowVersion { get; private set; }
  41. /// <summary>
  42. /// Gets or sets the rating type.
  43. /// If this is <c>null</c> it's the internal user rating.
  44. /// </summary>
  45. public virtual RatingSource? RatingType { get; set; }
  46. /// <inheritdoc />
  47. public void OnSavingChanges()
  48. {
  49. RowVersion++;
  50. }
  51. }
  52. }