Device.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. namespace Jellyfin.Data.Entities.Security
  4. {
  5. /// <summary>
  6. /// An entity representing a device.
  7. /// </summary>
  8. public class Device
  9. {
  10. /// <summary>
  11. /// Initializes a new instance of the <see cref="Device"/> class.
  12. /// </summary>
  13. /// <param name="userId">The user id.</param>
  14. /// <param name="appName">The app name.</param>
  15. /// <param name="appVersion">The app version.</param>
  16. /// <param name="deviceName">The device name.</param>
  17. /// <param name="deviceId">The device id.</param>
  18. public Device(Guid userId, string appName, string appVersion, string deviceName, string deviceId)
  19. {
  20. UserId = userId;
  21. AppName = appName;
  22. AppVersion = appVersion;
  23. DeviceName = deviceName;
  24. DeviceId = deviceId;
  25. DateCreated = DateTime.UtcNow;
  26. DateLastActivity = DateCreated;
  27. // Non-nullable for EF Core, as this is a required relationship.
  28. User = null!;
  29. }
  30. public int Id { get; private set; }
  31. /// <summary>
  32. /// Gets the user id.
  33. /// </summary>
  34. public Guid UserId { get; private set; }
  35. /// <summary>
  36. /// Gets or sets the app name.
  37. /// </summary>
  38. [MaxLength(64)]
  39. [StringLength(64)]
  40. public string AppName { get; set; }
  41. /// <summary>
  42. /// Gets or sets the app version.
  43. /// </summary>
  44. [MaxLength(32)]
  45. [StringLength(32)]
  46. public string AppVersion { get; set; }
  47. /// <summary>
  48. /// Gets or sets the device name.
  49. /// </summary>
  50. [MaxLength(64)]
  51. [StringLength(64)]
  52. public string DeviceName { get; set; }
  53. /// <summary>
  54. /// Gets or sets the device id.
  55. /// </summary>
  56. [MaxLength(256)]
  57. [StringLength(256)]
  58. public string DeviceId { get; set; }
  59. /// <summary>
  60. /// Gets or sets a value indicating whether this device is active.
  61. /// </summary>
  62. public bool IsActive { get; set; }
  63. /// <summary>
  64. /// Gets the date this device was created.
  65. /// </summary>
  66. public DateTime DateCreated { get; private set; }
  67. /// <summary>
  68. /// Gets or sets the date of last activity.
  69. /// </summary>
  70. public DateTime DateLastActivity { get; set; }
  71. /// <summary>
  72. /// Gets the user.
  73. /// </summary>
  74. public User User { get; private set; }
  75. }
  76. }