using ProtoBuf; using System; using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { /// /// Class UserItemData /// [ProtoContract] public class UserItemData { /// /// Gets or sets the user id. /// /// The user id. [ProtoMember(1)] public Guid UserId { get; set; } /// /// The _rating /// private float? _rating; /// /// Gets or sets the users 0-10 rating /// /// The rating. /// A 0-10 rating is required for UserItemData. /// A 0-10 rating is required for UserItemData. [ProtoMember(2)] public float? Rating { get { return _rating; } set { if (value.HasValue) { if (value.Value < 0 || value.Value > 10) { throw new ArgumentOutOfRangeException("A 0-10 rating is required for UserItemData."); } } _rating = value; } } /// /// Gets or sets the playback position ticks. /// /// The playback position ticks. [ProtoMember(3)] public long PlaybackPositionTicks { get; set; } /// /// Gets or sets the play count. /// /// The play count. [ProtoMember(4)] public int PlayCount { get; set; } /// /// Gets or sets a value indicating whether this instance is favorite. /// /// true if this instance is favorite; otherwise, false. [ProtoMember(5)] public bool IsFavorite { get; set; } /// /// Gets or sets the last played date. /// /// The last played date. [ProtoMember(6)] public DateTime? LastPlayedDate { get; set; } /// /// Gets or sets a value indicating whether this is played. /// /// true if played; otherwise, false. [ProtoMember(7)] public bool Played { get; set; } /// /// This is an interpreted property to indicate likes or dislikes /// This should never be serialized. /// /// null if [likes] contains no value, true if [likes]; otherwise, false. [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; } } } } }