You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
5.5 KiB
195 lines
5.5 KiB
4 years ago
|
#pragma warning disable CS1591
|
||
|
|
||
6 years ago
|
using System;
|
||
|
using System.ComponentModel.DataAnnotations;
|
||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||
|
|
||
4 years ago
|
namespace Jellyfin.Data.Entities.Libraries
|
||
6 years ago
|
{
|
||
5 years ago
|
public partial class Rating
|
||
|
{
|
||
|
partial void Init();
|
||
|
|
||
|
/// <summary>
|
||
|
/// Default constructor. Protected due to required properties, but present because EF needs it.
|
||
|
/// </summary>
|
||
|
protected Rating()
|
||
|
{
|
||
|
Init();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
|
||
|
/// </summary>
|
||
|
public static Rating CreateRatingUnsafe()
|
||
|
{
|
||
|
return new Rating();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Public constructor with required data.
|
||
5 years ago
|
/// </summary>
|
||
|
/// <param name="value"></param>
|
||
|
/// <param name="_metadata0"></param>
|
||
|
public Rating(double value, Metadata _metadata0)
|
||
|
{
|
||
|
this.Value = value;
|
||
|
|
||
4 years ago
|
if (_metadata0 == null)
|
||
|
{
|
||
|
throw new ArgumentNullException(nameof(_metadata0));
|
||
|
}
|
||
5 years ago
|
|
||
4 years ago
|
_metadata0.Ratings.Add(this);
|
||
5 years ago
|
|
||
|
Init();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Static create function (for use in LINQ queries, etc.)
|
||
|
/// </summary>
|
||
|
/// <param name="value"></param>
|
||
|
/// <param name="_metadata0"></param>
|
||
|
public static Rating Create(double value, Metadata _metadata0)
|
||
|
{
|
||
|
return new Rating(value, _metadata0);
|
||
|
}
|
||
|
|
||
|
/*************************************************************************
|
||
|
* Properties
|
||
|
*************************************************************************/
|
||
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Backing field for Id.
|
||
5 years ago
|
/// </summary>
|
||
|
internal int _Id;
|
||
|
/// <summary>
|
||
|
/// When provided in a partial class, allows value of Id to be changed before setting.
|
||
|
/// </summary>
|
||
|
partial void SetId(int oldValue, ref int newValue);
|
||
|
/// <summary>
|
||
|
/// When provided in a partial class, allows value of Id to be changed before returning.
|
||
|
/// </summary>
|
||
|
partial void GetId(ref int result);
|
||
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Identity, Indexed, Required.
|
||
5 years ago
|
/// </summary>
|
||
|
[Key]
|
||
|
[Required]
|
||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||
|
public int Id
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
int value = _Id;
|
||
|
GetId(ref value);
|
||
4 years ago
|
return _Id = value;
|
||
5 years ago
|
}
|
||
4 years ago
|
|
||
5 years ago
|
protected set
|
||
|
{
|
||
|
int oldValue = _Id;
|
||
|
SetId(oldValue, ref value);
|
||
|
if (oldValue != value)
|
||
|
{
|
||
|
_Id = value;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Backing field for Value.
|
||
5 years ago
|
/// </summary>
|
||
|
protected double _Value;
|
||
|
/// <summary>
|
||
|
/// When provided in a partial class, allows value of Value to be changed before setting.
|
||
|
/// </summary>
|
||
|
partial void SetValue(double oldValue, ref double newValue);
|
||
|
/// <summary>
|
||
|
/// When provided in a partial class, allows value of Value to be changed before returning.
|
||
|
/// </summary>
|
||
|
partial void GetValue(ref double result);
|
||
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Required.
|
||
5 years ago
|
/// </summary>
|
||
|
[Required]
|
||
|
public double Value
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
double value = _Value;
|
||
|
GetValue(ref value);
|
||
4 years ago
|
return _Value = value;
|
||
5 years ago
|
}
|
||
4 years ago
|
|
||
5 years ago
|
set
|
||
6 years ago
|
{
|
||
5 years ago
|
double oldValue = _Value;
|
||
|
SetValue(oldValue, ref value);
|
||
|
if (oldValue != value)
|
||
|
{
|
||
|
_Value = value;
|
||
|
}
|
||
6 years ago
|
}
|
||
5 years ago
|
}
|
||
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Backing field for Votes.
|
||
5 years ago
|
/// </summary>
|
||
|
protected int? _Votes;
|
||
|
/// <summary>
|
||
|
/// When provided in a partial class, allows value of Votes to be changed before setting.
|
||
|
/// </summary>
|
||
|
partial void SetVotes(int? oldValue, ref int? newValue);
|
||
|
/// <summary>
|
||
|
/// When provided in a partial class, allows value of Votes to be changed before returning.
|
||
|
/// </summary>
|
||
|
partial void GetVotes(ref int? result);
|
||
|
|
||
|
public int? Votes
|
||
|
{
|
||
|
get
|
||
6 years ago
|
{
|
||
5 years ago
|
int? value = _Votes;
|
||
|
GetVotes(ref value);
|
||
4 years ago
|
return _Votes = value;
|
||
6 years ago
|
}
|
||
4 years ago
|
|
||
5 years ago
|
set
|
||
6 years ago
|
{
|
||
5 years ago
|
int? oldValue = _Votes;
|
||
|
SetVotes(oldValue, ref value);
|
||
|
if (oldValue != value)
|
||
|
{
|
||
|
_Votes = value;
|
||
|
}
|
||
6 years ago
|
}
|
||
5 years ago
|
}
|
||
|
|
||
|
/// <summary>
|
||
4 years ago
|
/// Required, ConcurrenyToken.
|
||
5 years ago
|
/// </summary>
|
||
|
[ConcurrencyCheck]
|
||
|
[Required]
|
||
|
public uint RowVersion { get; set; }
|
||
|
|
||
|
public void OnSavingChanges()
|
||
|
{
|
||
|
RowVersion++;
|
||
|
}
|
||
|
|
||
|
/*************************************************************************
|
||
|
* Navigation properties
|
||
|
*************************************************************************/
|
||
|
|
||
|
/// <summary>
|
||
|
/// If this is NULL it's the internal user rating.
|
||
|
/// </summary>
|
||
|
[ForeignKey("RatingSource_RatingType_Id")]
|
||
|
public virtual RatingSource RatingType { get; set; }
|
||
|
}
|
||
6 years ago
|
}
|
||
|
|