UserItemData.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using ProtoBuf;
  2. using System;
  3. using System.Runtime.Serialization;
  4. namespace MediaBrowser.Controller.Entities
  5. {
  6. /// <summary>
  7. /// Class UserItemData
  8. /// </summary>
  9. [ProtoContract]
  10. public class UserItemData
  11. {
  12. /// <summary>
  13. /// Gets or sets the user id.
  14. /// </summary>
  15. /// <value>The user id.</value>
  16. [ProtoMember(1)]
  17. public Guid UserId { get; set; }
  18. /// <summary>
  19. /// The _rating
  20. /// </summary>
  21. private float? _rating;
  22. /// <summary>
  23. /// Gets or sets the users 0-10 rating
  24. /// </summary>
  25. /// <value>The rating.</value>
  26. /// <exception cref="System.ArgumentOutOfRangeException">A 0-10 rating is required for UserItemData.</exception>
  27. /// <exception cref="System.InvalidOperationException">A 0-10 rating is required for UserItemData.</exception>
  28. [ProtoMember(2)]
  29. public float? 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("A 0-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. [ProtoMember(3)]
  52. public long PlaybackPositionTicks { get; set; }
  53. /// <summary>
  54. /// Gets or sets the play count.
  55. /// </summary>
  56. /// <value>The play count.</value>
  57. [ProtoMember(4)]
  58. public int PlayCount { get; set; }
  59. /// <summary>
  60. /// Gets or sets a value indicating whether this instance is favorite.
  61. /// </summary>
  62. /// <value><c>true</c> if this instance is favorite; otherwise, <c>false</c>.</value>
  63. [ProtoMember(5)]
  64. public bool IsFavorite { get; set; }
  65. /// <summary>
  66. /// Gets or sets the last played date.
  67. /// </summary>
  68. /// <value>The last played date.</value>
  69. [ProtoMember(6)]
  70. public DateTime? LastPlayedDate { get; set; }
  71. /// <summary>
  72. /// Gets or sets a value indicating whether this <see cref="UserItemData" /> is played.
  73. /// </summary>
  74. /// <value><c>true</c> if played; otherwise, <c>false</c>.</value>
  75. [ProtoMember(7)]
  76. public bool Played { get; set; }
  77. /// <summary>
  78. /// This is an interpreted property to indicate likes or dislikes
  79. /// This should never be serialized.
  80. /// </summary>
  81. /// <value><c>null</c> if [likes] contains no value, <c>true</c> if [likes]; otherwise, <c>false</c>.</value>
  82. [IgnoreDataMember]
  83. public bool? Likes
  84. {
  85. get
  86. {
  87. if (Rating != null)
  88. {
  89. return Rating >= 6.5;
  90. }
  91. return null;
  92. }
  93. set
  94. {
  95. if (value.HasValue)
  96. {
  97. Rating = value.Value ? 10 : 1;
  98. }
  99. else
  100. {
  101. Rating = null;
  102. }
  103. }
  104. }
  105. }
  106. }