using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Jellyfin.Data.Interfaces; namespace Jellyfin.Data.Entities.Libraries { /// /// An entity representing a rating for an entity. /// public class Rating : IHasConcurrencyToken { /// /// Initializes a new instance of the class. /// /// The value. /// The metadata. public Rating(double value, Metadata metadata) { Value = value; if (metadata == null) { throw new ArgumentNullException(nameof(metadata)); } metadata.Ratings.Add(this); } /// /// Initializes a new instance of the class. /// /// /// Default constructor. Protected due to required properties, but present because EF needs it. /// protected Rating() { } /// /// Gets or sets the id. /// /// /// Identity, Indexed, Required. /// [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; protected set; } /// /// Gets or sets the value. /// /// /// Required. /// public double Value { get; set; } /// /// Gets or sets the number of votes. /// public int? Votes { get; set; } /// [ConcurrencyCheck] public uint RowVersion { get; set; } /// /// Gets or sets the rating type. /// If this is null it's the internal user rating. /// public virtual RatingSource RatingType { get; set; } /// public void OnSavingChanges() { RowVersion++; } } }