using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// This is the entity to store review ratings, not age ratings.
///
public class RatingSource : IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The minimum value.
/// The maximum value.
/// The rating.
public RatingSource(double minimumValue, double maximumValue, Rating rating)
{
MinimumValue = minimumValue;
MaximumValue = maximumValue;
if (rating == null)
{
throw new ArgumentNullException(nameof(rating));
}
rating.RatingType = this;
}
///
/// Initializes a new instance of the class.
///
///
/// Default constructor. Protected due to required properties, but present because EF needs it.
///
protected RatingSource()
{
}
///
/// Gets or sets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
///
/// Gets or sets the name.
///
///
/// Max length = 1024.
///
[MaxLength(1024)]
[StringLength(1024)]
public string Name { get; set; }
///
/// Gets or sets the minimum value.
///
///
/// Required.
///
public double MinimumValue { get; set; }
///
/// Gets or sets the maximum value.
///
///
/// Required.
///
public double MaximumValue { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; set; }
///
/// Gets or sets the metadata source.
///
public virtual MetadataProviderId Source { get; set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}