jellyfin/MediaBrowser.Controller/Entities/UserItemData.cs

68 lines
1.6 KiB
C#
Raw Normal View History

using System;
2012-09-09 20:32:51 +02:00
using System.Runtime.Serialization;
2012-07-12 08:55:27 +02:00
2012-09-11 16:16:43 +02:00
namespace MediaBrowser.Controller.Entities
2012-07-12 08:55:27 +02:00
{
public class UserItemData
{
2012-09-11 20:20:12 +02:00
private float? _Rating;
2012-09-09 20:32:51 +02:00
/// <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 08:55:27 +02:00
public long PlaybackPositionTicks { get; set; }
public int PlayCount { get; set; }
2012-07-12 08:55:27 +02:00
2012-09-09 20:32:51 +02: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 08:55:27 +02:00
}
}