BookMetadata.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. namespace Jellyfin.Data.Entities
  5. {
  6. public partial class BookMetadata : Metadata
  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 BookMetadata()
  13. {
  14. Publishers = new HashSet<Company>();
  15. Init();
  16. }
  17. /// <summary>
  18. /// Replaces default constructor, since it's protected. Caller assumes responsibility for setting all required values before saving.
  19. /// </summary>
  20. public static BookMetadata CreateBookMetadataUnsafe()
  21. {
  22. return new BookMetadata();
  23. }
  24. /// <summary>
  25. /// Public constructor with required data.
  26. /// </summary>
  27. /// <param name="title">The title or name of the object.</param>
  28. /// <param name="language">ISO-639-3 3-character language codes.</param>
  29. /// <param name="_book0"></param>
  30. public BookMetadata(string title, string language, DateTime dateadded, DateTime datemodified, Book _book0)
  31. {
  32. if (string.IsNullOrEmpty(title)) throw new ArgumentNullException(nameof(title));
  33. this.Title = title;
  34. if (string.IsNullOrEmpty(language)) throw new ArgumentNullException(nameof(language));
  35. this.Language = language;
  36. if (_book0 == null) throw new ArgumentNullException(nameof(_book0));
  37. _book0.BookMetadata.Add(this);
  38. this.Publishers = new HashSet<Company>();
  39. Init();
  40. }
  41. /// <summary>
  42. /// Static create function (for use in LINQ queries, etc.)
  43. /// </summary>
  44. /// <param name="title">The title or name of the object.</param>
  45. /// <param name="language">ISO-639-3 3-character language codes.</param>
  46. /// <param name="_book0"></param>
  47. public static BookMetadata Create(string title, string language, DateTime dateadded, DateTime datemodified, Book _book0)
  48. {
  49. return new BookMetadata(title, language, dateadded, datemodified, _book0);
  50. }
  51. /*************************************************************************
  52. * Properties
  53. *************************************************************************/
  54. /// <summary>
  55. /// Backing field for ISBN.
  56. /// </summary>
  57. protected long? _ISBN;
  58. /// <summary>
  59. /// When provided in a partial class, allows value of ISBN to be changed before setting.
  60. /// </summary>
  61. partial void SetISBN(long? oldValue, ref long? newValue);
  62. /// <summary>
  63. /// When provided in a partial class, allows value of ISBN to be changed before returning.
  64. /// </summary>
  65. partial void GetISBN(ref long? result);
  66. public long? ISBN
  67. {
  68. get
  69. {
  70. long? value = _ISBN;
  71. GetISBN(ref value);
  72. return _ISBN = value;
  73. }
  74. set
  75. {
  76. long? oldValue = _ISBN;
  77. SetISBN(oldValue, ref value);
  78. if (oldValue != value)
  79. {
  80. _ISBN = value;
  81. }
  82. }
  83. }
  84. /*************************************************************************
  85. * Navigation properties
  86. *************************************************************************/
  87. [ForeignKey("Company_Publishers_Id")]
  88. public virtual ICollection<Company> Publishers { get; protected set; }
  89. }
  90. }