ItemDisplayPreferences.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Jellyfin.Data.Enums;
  5. namespace Jellyfin.Data.Entities
  6. {
  7. /// <summary>
  8. /// An entity that represents a user's display preferences for a specific item.
  9. /// </summary>
  10. public class ItemDisplayPreferences
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="ItemDisplayPreferences"/> class.
  14. /// </summary>
  15. /// <param name="userId">The user id.</param>
  16. /// <param name="itemId">The item id.</param>
  17. /// <param name="client">The client.</param>
  18. public ItemDisplayPreferences(Guid userId, Guid itemId, string client)
  19. {
  20. UserId = userId;
  21. ItemId = itemId;
  22. Client = client;
  23. SortBy = "SortName";
  24. SortOrder = SortOrder.Ascending;
  25. RememberSorting = false;
  26. RememberIndexing = false;
  27. }
  28. /// <summary>
  29. /// Initializes a new instance of the <see cref="ItemDisplayPreferences"/> class.
  30. /// </summary>
  31. protected ItemDisplayPreferences()
  32. {
  33. }
  34. /// <summary>
  35. /// Gets or sets the Id.
  36. /// </summary>
  37. /// <remarks>
  38. /// Required.
  39. /// </remarks>
  40. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  41. public int Id { get; protected set; }
  42. /// <summary>
  43. /// Gets or sets the user Id.
  44. /// </summary>
  45. /// <remarks>
  46. /// Required.
  47. /// </remarks>
  48. public Guid UserId { get; set; }
  49. /// <summary>
  50. /// Gets or sets the id of the associated item.
  51. /// </summary>
  52. /// <remarks>
  53. /// Required.
  54. /// </remarks>
  55. public Guid ItemId { get; set; }
  56. /// <summary>
  57. /// Gets or sets the client string.
  58. /// </summary>
  59. /// <remarks>
  60. /// Required. Max Length = 32.
  61. /// </remarks>
  62. [Required]
  63. [MaxLength(32)]
  64. [StringLength(32)]
  65. public string Client { get; set; }
  66. /// <summary>
  67. /// Gets or sets the view type.
  68. /// </summary>
  69. /// <remarks>
  70. /// Required.
  71. /// </remarks>
  72. public ViewType ViewType { get; set; }
  73. /// <summary>
  74. /// Gets or sets a value indicating whether the indexing should be remembered.
  75. /// </summary>
  76. /// <remarks>
  77. /// Required.
  78. /// </remarks>
  79. public bool RememberIndexing { get; set; }
  80. /// <summary>
  81. /// Gets or sets what the view should be indexed by.
  82. /// </summary>
  83. public IndexingKind? IndexBy { get; set; }
  84. /// <summary>
  85. /// Gets or sets a value indicating whether the sorting type should be remembered.
  86. /// </summary>
  87. /// <remarks>
  88. /// Required.
  89. /// </remarks>
  90. public bool RememberSorting { get; set; }
  91. /// <summary>
  92. /// Gets or sets what the view should be sorted by.
  93. /// </summary>
  94. /// <remarks>
  95. /// Required.
  96. /// </remarks>
  97. [Required]
  98. [MaxLength(64)]
  99. [StringLength(64)]
  100. public string SortBy { get; set; }
  101. /// <summary>
  102. /// Gets or sets the sort order.
  103. /// </summary>
  104. /// <remarks>
  105. /// Required.
  106. /// </remarks>
  107. public SortOrder SortOrder { get; set; }
  108. }
  109. }