Release.cs 2.0 KB

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