Season.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. namespace Jellyfin.Data.Entities
  6. {
  7. public partial class Season : LibraryItem
  8. {
  9. partial void Init();
  10. /// <summary>
  11. /// Default constructor. Protected due to required properties, but present because EF needs it.
  12. /// </summary>
  13. protected Season()
  14. {
  15. // NOTE: This class has one-to-one associations with LibraryRoot, LibraryItem and CollectionItem.
  16. // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other.
  17. SeasonMetadata = new HashSet<SeasonMetadata>();
  18. Episodes = new HashSet<Episode>();
  19. Init();
  20. }
  21. /// <summary>
  22. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  23. /// </summary>
  24. public static Season CreateSeasonUnsafe()
  25. {
  26. return new Season();
  27. }
  28. /// <summary>
  29. /// Public constructor with required data.
  30. /// </summary>
  31. /// <param name="urlid">This is whats gets displayed in the Urls and API requests. This could also be a string.</param>
  32. /// <param name="dateadded">The date the object was added.</param>
  33. /// <param name="_series0"></param>
  34. public Season(Guid urlid, DateTime dateadded, Series _series0)
  35. {
  36. // NOTE: This class has one-to-one associations with LibraryRoot, LibraryItem and CollectionItem.
  37. // One-to-one associations are not validated in constructors since this causes a scenario where each one must be constructed before the other.
  38. this.UrlId = urlid;
  39. if (_series0 == null)
  40. {
  41. throw new ArgumentNullException(nameof(_series0));
  42. }
  43. _series0.Seasons.Add(this);
  44. this.SeasonMetadata = new HashSet<SeasonMetadata>();
  45. this.Episodes = new HashSet<Episode>();
  46. Init();
  47. }
  48. /// <summary>
  49. /// Static create function (for use in LINQ queries, etc.)
  50. /// </summary>
  51. /// <param name="urlid">This is whats gets displayed in the Urls and API requests. This could also be a string.</param>
  52. /// <param name="dateadded">The date the object was added.</param>
  53. /// <param name="_series0"></param>
  54. public static Season Create(Guid urlid, DateTime dateadded, Series _series0)
  55. {
  56. return new Season(urlid, dateadded, _series0);
  57. }
  58. /*************************************************************************
  59. * Properties
  60. *************************************************************************/
  61. /// <summary>
  62. /// Backing field for SeasonNumber.
  63. /// </summary>
  64. protected int? _SeasonNumber;
  65. /// <summary>
  66. /// When provided in a partial class, allows value of SeasonNumber to be changed before setting.
  67. /// </summary>
  68. partial void SetSeasonNumber(int? oldValue, ref int? newValue);
  69. /// <summary>
  70. /// When provided in a partial class, allows value of SeasonNumber to be changed before returning.
  71. /// </summary>
  72. partial void GetSeasonNumber(ref int? result);
  73. public int? SeasonNumber
  74. {
  75. get
  76. {
  77. int? value = _SeasonNumber;
  78. GetSeasonNumber(ref value);
  79. return _SeasonNumber = value;
  80. }
  81. set
  82. {
  83. int? oldValue = _SeasonNumber;
  84. SetSeasonNumber(oldValue, ref value);
  85. if (oldValue != value)
  86. {
  87. _SeasonNumber = value;
  88. }
  89. }
  90. }
  91. /*************************************************************************
  92. * Navigation properties
  93. *************************************************************************/
  94. [ForeignKey("SeasonMetadata_SeasonMetadata_Id")]
  95. public virtual ICollection<SeasonMetadata> SeasonMetadata { get; protected set; }
  96. [ForeignKey("Episode_Episodes_Id")]
  97. public virtual ICollection<Episode> Episodes { get; protected set; }
  98. }
  99. }