Device.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. }
  28. public int Id { get; private set; }
  29. /// <summary>
  30. /// Gets the user id.
  31. /// </summary>
  32. public Guid UserId { get; private set; }
  33. /// <summary>
  34. /// Gets or sets the app name.
  35. /// </summary>
  36. [MaxLength(64)]
  37. [StringLength(64)]
  38. public string AppName { get; set; }
  39. /// <summary>
  40. /// Gets or sets the app version.
  41. /// </summary>
  42. [MaxLength(32)]
  43. [StringLength(32)]
  44. public string AppVersion { get; set; }
  45. /// <summary>
  46. /// Gets or sets the device name.
  47. /// </summary>
  48. [MaxLength(64)]
  49. [StringLength(64)]
  50. public string DeviceName { get; set; }
  51. /// <summary>
  52. /// Gets or sets the device id.
  53. /// </summary>
  54. [MaxLength(256)]
  55. [StringLength(256)]
  56. public string DeviceId { get; set; }
  57. /// <summary>
  58. /// Gets or sets a value indicating whether this device is active.
  59. /// </summary>
  60. public bool IsActive { get; set; }
  61. /// <summary>
  62. /// Gets the date this device was created.
  63. /// </summary>
  64. public DateTime DateCreated { get; private set; }
  65. /// <summary>
  66. /// Gets or sets the date of last activity.
  67. /// </summary>
  68. public DateTime DateLastActivity { get; set; }
  69. }
  70. }