UserItemData.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using System.Runtime.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. /// The _rating
  17. /// </summary>
  18. private float? _rating;
  19. /// <summary>
  20. /// Gets or sets the users 0-10 rating
  21. /// </summary>
  22. /// <value>The rating.</value>
  23. /// <exception cref="System.ArgumentOutOfRangeException">Rating;A 0 to 10 rating is required for UserItemData.</exception>
  24. public float? Rating
  25. {
  26. get
  27. {
  28. return _rating;
  29. }
  30. set
  31. {
  32. if (value.HasValue)
  33. {
  34. if (value.Value < 0 || value.Value > 10)
  35. {
  36. throw new ArgumentOutOfRangeException("value", "A 0 to 10 rating is required for UserItemData.");
  37. }
  38. }
  39. _rating = value;
  40. }
  41. }
  42. /// <summary>
  43. /// Gets or sets the playback position ticks.
  44. /// </summary>
  45. /// <value>The playback position ticks.</value>
  46. public long PlaybackPositionTicks { get; set; }
  47. /// <summary>
  48. /// Gets or sets the play count.
  49. /// </summary>
  50. /// <value>The play count.</value>
  51. public int PlayCount { get; set; }
  52. /// <summary>
  53. /// Gets or sets a value indicating whether this instance is favorite.
  54. /// </summary>
  55. /// <value><c>true</c> if this instance is favorite; otherwise, <c>false</c>.</value>
  56. public bool IsFavorite { get; set; }
  57. /// <summary>
  58. /// Gets or sets the last played date.
  59. /// </summary>
  60. /// <value>The last played date.</value>
  61. public DateTime? LastPlayedDate { get; set; }
  62. /// <summary>
  63. /// Gets or sets a value indicating whether this <see cref="UserItemData" /> is played.
  64. /// </summary>
  65. /// <value><c>true</c> if played; otherwise, <c>false</c>.</value>
  66. public bool Played { get; set; }
  67. /// <summary>
  68. /// This is an interpreted property to indicate likes or dislikes
  69. /// This should never be serialized.
  70. /// </summary>
  71. /// <value><c>null</c> if [likes] contains no value, <c>true</c> if [likes]; otherwise, <c>false</c>.</value>
  72. [IgnoreDataMember]
  73. public bool? Likes
  74. {
  75. get
  76. {
  77. if (Rating != null)
  78. {
  79. return Rating >= 6.5;
  80. }
  81. return null;
  82. }
  83. set
  84. {
  85. if (value.HasValue)
  86. {
  87. Rating = value.Value ? 10 : 1;
  88. }
  89. else
  90. {
  91. Rating = null;
  92. }
  93. }
  94. }
  95. }
  96. }