Chapter.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Jellyfin.Data.Interfaces;
  5. namespace Jellyfin.Data.Entities.Libraries
  6. {
  7. /// <summary>
  8. /// An entity representing a chapter.
  9. /// </summary>
  10. public class Chapter : IHasConcurrencyToken
  11. {
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="Chapter"/> class.
  14. /// </summary>
  15. /// <param name="language">ISO-639-3 3-character language codes.</param>
  16. /// <param name="startTime">The start time for this chapter.</param>
  17. public Chapter(string language, long startTime)
  18. {
  19. ArgumentException.ThrowIfNullOrEmpty(language);
  20. Language = language;
  21. StartTime = startTime;
  22. }
  23. /// <summary>
  24. /// Gets the id.
  25. /// </summary>
  26. /// <remarks>
  27. /// Identity, Indexed, Required.
  28. /// </remarks>
  29. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  30. public int Id { get; private set; }
  31. /// <summary>
  32. /// Gets or sets the name.
  33. /// </summary>
  34. /// <remarks>
  35. /// Max length = 1024.
  36. /// </remarks>
  37. [MaxLength(1024)]
  38. [StringLength(1024)]
  39. public string? Name { get; set; }
  40. /// <summary>
  41. /// Gets or sets the language.
  42. /// </summary>
  43. /// <remarks>
  44. /// Required, Min length = 3, Max length = 3
  45. /// ISO-639-3 3-character language codes.
  46. /// </remarks>
  47. [MinLength(3)]
  48. [MaxLength(3)]
  49. [StringLength(3)]
  50. public string Language { get; set; }
  51. /// <summary>
  52. /// Gets or sets the start time.
  53. /// </summary>
  54. /// <remarks>
  55. /// Required.
  56. /// </remarks>
  57. public long StartTime { get; set; }
  58. /// <summary>
  59. /// Gets or sets the end time.
  60. /// </summary>
  61. public long? EndTime { get; set; }
  62. /// <inheritdoc />
  63. [ConcurrencyCheck]
  64. public uint RowVersion { get; private set; }
  65. /// <inheritdoc />
  66. public void OnSavingChanges()
  67. {
  68. RowVersion++;
  69. }
  70. }
  71. }