UserItemData.cs 3.2 KB

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