2
0

UserItemData.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using MediaBrowser.Model.Serialization;
  3. namespace MediaBrowser.Controller.Entities
  4. {
  5. /// <summary>
  6. /// Class UserItemData
  7. /// </summary>
  8. public class UserItemData
  9. {
  10. /// <summary>
  11. /// Gets or sets the user id.
  12. /// </summary>
  13. /// <value>The user id.</value>
  14. public Guid UserId { get; set; }
  15. /// <summary>
  16. /// Gets or sets the key.
  17. /// </summary>
  18. /// <value>The key.</value>
  19. public string Key { get; set; }
  20. /// <summary>
  21. /// The _rating
  22. /// </summary>
  23. private double? _rating;
  24. /// <summary>
  25. /// Gets or sets the users 0-10 rating
  26. /// </summary>
  27. /// <value>The rating.</value>
  28. /// <exception cref="System.ArgumentOutOfRangeException">Rating;A 0 to 10 rating is required for UserItemData.</exception>
  29. public double? Rating
  30. {
  31. get
  32. {
  33. return _rating;
  34. }
  35. set
  36. {
  37. if (value.HasValue)
  38. {
  39. if (value.Value < 0 || value.Value > 10)
  40. {
  41. throw new ArgumentOutOfRangeException("value", "A 0 to 10 rating is required for UserItemData.");
  42. }
  43. }
  44. _rating = value;
  45. }
  46. }
  47. /// <summary>
  48. /// Gets or sets the playback position ticks.
  49. /// </summary>
  50. /// <value>The playback position ticks.</value>
  51. public long PlaybackPositionTicks { get; set; }
  52. /// <summary>
  53. /// Gets or sets the play count.
  54. /// </summary>
  55. /// <value>The play count.</value>
  56. public int PlayCount { get; set; }
  57. /// <summary>
  58. /// Gets or sets a value indicating whether this instance is favorite.
  59. /// </summary>
  60. /// <value><c>true</c> if this instance is favorite; otherwise, <c>false</c>.</value>
  61. public bool IsFavorite { get; set; }
  62. /// <summary>
  63. /// Gets or sets the last played date.
  64. /// </summary>
  65. /// <value>The last played date.</value>
  66. public DateTime? LastPlayedDate { get; set; }
  67. /// <summary>
  68. /// Gets or sets a value indicating whether this <see cref="UserItemData" /> is played.
  69. /// </summary>
  70. /// <value><c>true</c> if played; otherwise, <c>false</c>.</value>
  71. public bool Played { get; set; }
  72. /// <summary>
  73. /// Gets or sets the index of the audio stream.
  74. /// </summary>
  75. /// <value>The index of the audio stream.</value>
  76. public int? AudioStreamIndex { get; set; }
  77. /// <summary>
  78. /// Gets or sets the index of the subtitle stream.
  79. /// </summary>
  80. /// <value>The index of the subtitle stream.</value>
  81. public int? SubtitleStreamIndex { get; set; }
  82. public const double MinLikeValue = 6.5;
  83. /// <summary>
  84. /// This is an interpreted property to indicate likes or dislikes
  85. /// This should never be serialized.
  86. /// </summary>
  87. /// <value><c>null</c> if [likes] contains no value, <c>true</c> if [likes]; otherwise, <c>false</c>.</value>
  88. [IgnoreDataMember]
  89. public bool? Likes
  90. {
  91. get
  92. {
  93. if (Rating != null)
  94. {
  95. return Rating >= MinLikeValue;
  96. }
  97. return null;
  98. }
  99. set
  100. {
  101. if (value.HasValue)
  102. {
  103. Rating = value.Value ? 10 : 1;
  104. }
  105. else
  106. {
  107. Rating = null;
  108. }
  109. }
  110. }
  111. }
  112. }