Episode.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. namespace Jellyfin.Data.Entities
  5. {
  6. public partial class Episode : 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 Episode()
  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. Releases = new HashSet<Release>();
  17. EpisodeMetadata = new HashSet<EpisodeMetadata>();
  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 Episode CreateEpisodeUnsafe()
  24. {
  25. return new Episode();
  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="_season0"></param>
  32. public Episode(Guid urlid, DateTime dateadded, Season _season0)
  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 (_season0 == null) throw new ArgumentNullException(nameof(_season0));
  38. _season0.Episodes.Add(this);
  39. this.Releases = new HashSet<Release>();
  40. this.EpisodeMetadata = new HashSet<EpisodeMetadata>();
  41. Init();
  42. }
  43. /// <summary>
  44. /// Static create function (for use in LINQ queries, etc.)
  45. /// </summary>
  46. /// <param name="urlid">This is whats gets displayed in the Urls and API requests. This could also be a string.</param>
  47. /// <param name="_season0"></param>
  48. public static Episode Create(Guid urlid, DateTime dateadded, Season _season0)
  49. {
  50. return new Episode(urlid, dateadded, _season0);
  51. }
  52. /*************************************************************************
  53. * Properties
  54. *************************************************************************/
  55. /// <summary>
  56. /// Backing field for EpisodeNumber
  57. /// </summary>
  58. protected int? _EpisodeNumber;
  59. /// <summary>
  60. /// When provided in a partial class, allows value of EpisodeNumber to be changed before setting.
  61. /// </summary>
  62. partial void SetEpisodeNumber(int? oldValue, ref int? newValue);
  63. /// <summary>
  64. /// When provided in a partial class, allows value of EpisodeNumber to be changed before returning.
  65. /// </summary>
  66. partial void GetEpisodeNumber(ref int? result);
  67. public int? EpisodeNumber
  68. {
  69. get
  70. {
  71. int? value = _EpisodeNumber;
  72. GetEpisodeNumber(ref value);
  73. return (_EpisodeNumber = value);
  74. }
  75. set
  76. {
  77. int? oldValue = _EpisodeNumber;
  78. SetEpisodeNumber(oldValue, ref value);
  79. if (oldValue != value)
  80. {
  81. _EpisodeNumber = value;
  82. }
  83. }
  84. }
  85. /*************************************************************************
  86. * Navigation properties
  87. *************************************************************************/
  88. [ForeignKey("Release_Releases_Id")]
  89. public virtual ICollection<Release> Releases { get; protected set; }
  90. [ForeignKey("EpisodeMetadata_EpisodeMetadata_Id")]
  91. public virtual ICollection<EpisodeMetadata> EpisodeMetadata { get; protected set; }
  92. }
  93. }