Release.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #pragma warning disable CA2227
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel.DataAnnotations;
  5. using System.ComponentModel.DataAnnotations.Schema;
  6. using Jellyfin.Data.Interfaces;
  7. namespace Jellyfin.Data.Entities.Libraries
  8. {
  9. /// <summary>
  10. /// An entity representing a release for a library item, eg. Director's cut vs. standard.
  11. /// </summary>
  12. public class Release : IHasConcurrencyToken
  13. {
  14. /// <summary>
  15. /// Initializes a new instance of the <see cref="Release"/> class.
  16. /// </summary>
  17. /// <param name="name">The name of this release.</param>
  18. /// <param name="owner">The owner of this release.</param>
  19. public Release(string name, IHasReleases owner)
  20. {
  21. if (string.IsNullOrEmpty(name))
  22. {
  23. throw new ArgumentNullException(nameof(name));
  24. }
  25. Name = name;
  26. owner?.Releases.Add(this);
  27. MediaFiles = new HashSet<MediaFile>();
  28. Chapters = new HashSet<Chapter>();
  29. }
  30. /// <summary>
  31. /// Initializes a new instance of the <see cref="Release"/> class.
  32. /// </summary>
  33. /// <remarks>
  34. /// Default constructor. Protected due to required properties, but present because EF needs it.
  35. /// </remarks>
  36. protected Release()
  37. {
  38. }
  39. /// <summary>
  40. /// Gets or sets the id.
  41. /// </summary>
  42. /// <remarks>
  43. /// Identity, Indexed, Required.
  44. /// </remarks>
  45. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  46. public int Id { get; protected set; }
  47. /// <summary>
  48. /// Gets or sets the name.
  49. /// </summary>
  50. /// <remarks>
  51. /// Required, Max length = 1024.
  52. /// </remarks>
  53. [Required]
  54. [MaxLength(1024)]
  55. [StringLength(1024)]
  56. public string Name { get; set; }
  57. /// <inheritdoc />
  58. [ConcurrencyCheck]
  59. public uint RowVersion { get; set; }
  60. /// <summary>
  61. /// Gets or sets a collection containing the media files for this release.
  62. /// </summary>
  63. public virtual ICollection<MediaFile> MediaFiles { get; protected set; }
  64. /// <summary>
  65. /// Gets or sets a collection containing the chapters for this release.
  66. /// </summary>
  67. public virtual ICollection<Chapter> Chapters { get; protected set; }
  68. /// <inheritdoc />
  69. public void OnSavingChanges()
  70. {
  71. RowVersion++;
  72. }
  73. }
  74. }