Season.cs 4.1 KB

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