BookMetadata.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Jellyfin.Data.Interfaces;
  5. namespace Jellyfin.Data.Entities.Libraries
  6. {
  7. /// <summary>
  8. /// An entity containing metadata for a book.
  9. /// </summary>
  10. public class BookMetadata : Metadata, IHasCompanies
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="BookMetadata"/> class.
  14. /// </summary>
  15. /// <param name="title">The title or name of the object.</param>
  16. /// <param name="language">ISO-639-3 3-character language codes.</param>
  17. /// <param name="book">The book.</param>
  18. public BookMetadata(string title, string language, Book book) : base(title, language)
  19. {
  20. if (book == null)
  21. {
  22. throw new ArgumentNullException(nameof(book));
  23. }
  24. book.BookMetadata.Add(this);
  25. Publishers = new HashSet<Company>();
  26. }
  27. /// <summary>
  28. /// Initializes a new instance of the <see cref="BookMetadata"/> class.
  29. /// </summary>
  30. /// <remarks>
  31. /// Default constructor. Protected due to required properties, but present because EF needs it.
  32. /// </remarks>
  33. protected BookMetadata()
  34. {
  35. }
  36. /// <summary>
  37. /// Gets or sets the ISBN.
  38. /// </summary>
  39. public long? Isbn { get; set; }
  40. /// <summary>
  41. /// Gets or sets a collection of the publishers for this book.
  42. /// </summary>
  43. public virtual ICollection<Company> Publishers { get; protected set; }
  44. /// <inheritdoc />
  45. [NotMapped]
  46. public ICollection<Company> Companies => Publishers;
  47. }
  48. }