Release.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. public Release(string name)
  19. {
  20. if (string.IsNullOrEmpty(name))
  21. {
  22. throw new ArgumentNullException(nameof(name));
  23. }
  24. Name = name;
  25. MediaFiles = new HashSet<MediaFile>();
  26. Chapters = new HashSet<Chapter>();
  27. }
  28. /// <summary>
  29. /// Gets or sets the id.
  30. /// </summary>
  31. /// <remarks>
  32. /// Identity, Indexed, Required.
  33. /// </remarks>
  34. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  35. public int Id { get; protected set; }
  36. /// <summary>
  37. /// Gets or sets the name.
  38. /// </summary>
  39. /// <remarks>
  40. /// Required, Max length = 1024.
  41. /// </remarks>
  42. [MaxLength(1024)]
  43. [StringLength(1024)]
  44. public string Name { get; set; }
  45. /// <inheritdoc />
  46. [ConcurrencyCheck]
  47. public uint RowVersion { get; set; }
  48. /// <summary>
  49. /// Gets or sets a collection containing the media files for this release.
  50. /// </summary>
  51. public virtual ICollection<MediaFile> MediaFiles { get; protected set; }
  52. /// <summary>
  53. /// Gets or sets a collection containing the chapters for this release.
  54. /// </summary>
  55. public virtual ICollection<Chapter> Chapters { get; protected set; }
  56. /// <inheritdoc />
  57. public void OnSavingChanges()
  58. {
  59. RowVersion++;
  60. }
  61. }
  62. }