jellyfin-server/MediaBrowser.Model/Entities/UserItemData.cs

68 lines
1.6 KiB
C#
Raw Normal View History

using System;
2012-09-09 18:32:51 +00:00
using System.Runtime.Serialization;
2012-07-12 06:55:27 +00:00
namespace MediaBrowser.Model.Entities
2012-07-12 06:55:27 +00:00
{
public class UserItemData
{
2012-09-09 18:32:51 +00:00
private float? _Rating = null;
/// <summary>
/// Gets or sets the users 0-10 rating
/// </summary>
public float? Rating
{
get
{
return _Rating;
}
set
{
if (value.HasValue)
{
if (value.Value < 0 || value.Value > 10)
{
throw new InvalidOperationException("A 0-10 rating is required for UserItemData.");
}
}
_Rating = value;
}
}
2012-07-12 06:55:27 +00:00
public long PlaybackPositionTicks { get; set; }
public int PlayCount { get; set; }
2012-07-12 06:55:27 +00:00
2012-09-09 18:32:51 +00:00
public bool IsFavorite { get; set; }
/// <summary>
/// This is an interpreted property to indicate likes or dislikes
/// This should never be serialized.
/// </summary>
[IgnoreDataMember]
public bool? Likes
{
get
{
if (Rating != null)
{
return Rating >= 6.5;
}
return null;
}
set
{
if (value.HasValue)
{
Rating = value.Value ? 10 : 1;
}
else
{
Rating = null;
}
}
}
2012-07-12 06:55:27 +00:00
}
}