ProviderMapping.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. namespace Jellyfin.Data.Entities
  5. {
  6. public partial class ProviderMapping
  7. {
  8. partial void Init();
  9. /// <summary>
  10. /// Default constructor. Protected due to required properties, but present because EF needs it.
  11. /// </summary>
  12. protected ProviderMapping()
  13. {
  14. Init();
  15. }
  16. /// <summary>
  17. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  18. /// </summary>
  19. public static ProviderMapping CreateProviderMappingUnsafe()
  20. {
  21. return new ProviderMapping();
  22. }
  23. /// <summary>
  24. /// Public constructor with required data
  25. /// </summary>
  26. /// <param name="providername"></param>
  27. /// <param name="providersecrets"></param>
  28. /// <param name="providerdata"></param>
  29. /// <param name="_user0"></param>
  30. /// <param name="_group1"></param>
  31. public ProviderMapping(string providername, string providersecrets, string providerdata, User _user0, Group _group1)
  32. {
  33. if (string.IsNullOrEmpty(providername)) throw new ArgumentNullException(nameof(providername));
  34. this.ProviderName = providername;
  35. if (string.IsNullOrEmpty(providersecrets)) throw new ArgumentNullException(nameof(providersecrets));
  36. this.ProviderSecrets = providersecrets;
  37. if (string.IsNullOrEmpty(providerdata)) throw new ArgumentNullException(nameof(providerdata));
  38. this.ProviderData = providerdata;
  39. if (_user0 == null) throw new ArgumentNullException(nameof(_user0));
  40. _user0.ProviderMappings.Add(this);
  41. if (_group1 == null) throw new ArgumentNullException(nameof(_group1));
  42. _group1.ProviderMappings.Add(this);
  43. Init();
  44. }
  45. /// <summary>
  46. /// Static create function (for use in LINQ queries, etc.)
  47. /// </summary>
  48. /// <param name="providername"></param>
  49. /// <param name="providersecrets"></param>
  50. /// <param name="providerdata"></param>
  51. /// <param name="_user0"></param>
  52. /// <param name="_group1"></param>
  53. public static ProviderMapping Create(string providername, string providersecrets, string providerdata, User _user0, Group _group1)
  54. {
  55. return new ProviderMapping(providername, providersecrets, providerdata, _user0, _group1);
  56. }
  57. /*************************************************************************
  58. * Properties
  59. *************************************************************************/
  60. /// <summary>
  61. /// Identity, Indexed, Required
  62. /// </summary>
  63. [Key]
  64. [Required]
  65. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  66. public int Id { get; protected set; }
  67. /// <summary>
  68. /// Required, Max length = 255
  69. /// </summary>
  70. [Required]
  71. [MaxLength(255)]
  72. [StringLength(255)]
  73. public string ProviderName { get; set; }
  74. /// <summary>
  75. /// Required, Max length = 65535
  76. /// </summary>
  77. [Required]
  78. [MaxLength(65535)]
  79. [StringLength(65535)]
  80. public string ProviderSecrets { get; set; }
  81. /// <summary>
  82. /// Required, Max length = 65535
  83. /// </summary>
  84. [Required]
  85. [MaxLength(65535)]
  86. [StringLength(65535)]
  87. public string ProviderData { get; set; }
  88. /// <summary>
  89. /// Required, ConcurrenyToken
  90. /// </summary>
  91. [ConcurrencyCheck]
  92. [Required]
  93. public uint RowVersion { get; set; }
  94. public void OnSavingChanges()
  95. {
  96. RowVersion++;
  97. }
  98. /*************************************************************************
  99. * Navigation properties
  100. *************************************************************************/
  101. }
  102. }