2020-09-01 17:36:45 +02:00
|
|
|
#pragma warning disable CA2227
|
|
|
|
|
2019-06-01 22:40:01 +02:00
|
|
|
using System;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2020-08-31 00:50:54 +02:00
|
|
|
using Jellyfin.Data.Interfaces;
|
2019-06-01 22:40:01 +02:00
|
|
|
|
2020-08-29 19:30:09 +02:00
|
|
|
namespace Jellyfin.Data.Entities.Libraries
|
2019-06-01 22:40:01 +02:00
|
|
|
{
|
2020-08-31 00:50:54 +02:00
|
|
|
/// <summary>
|
|
|
|
/// An entity representing a chapter.
|
|
|
|
/// </summary>
|
|
|
|
public class Chapter : IHasConcurrencyToken
|
2020-05-02 23:56:05 +02:00
|
|
|
{
|
|
|
|
/// <summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// Initializes a new instance of the <see cref="Chapter"/> class.
|
2020-05-02 23:56:05 +02:00
|
|
|
/// </summary>
|
2020-06-19 12:21:49 +02:00
|
|
|
/// <param name="language">ISO-639-3 3-character language codes.</param>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// <param name="startTime">The start time for this chapter.</param>
|
|
|
|
/// <param name="release">The release.</param>
|
|
|
|
public Chapter(string language, long startTime, Release release)
|
2020-05-02 23:56:05 +02:00
|
|
|
{
|
2020-06-20 10:35:29 +02:00
|
|
|
if (string.IsNullOrEmpty(language))
|
|
|
|
{
|
|
|
|
throw new ArgumentNullException(nameof(language));
|
|
|
|
}
|
|
|
|
|
2020-08-31 00:50:54 +02:00
|
|
|
Language = language;
|
|
|
|
StartTime = startTime;
|
2019-06-01 22:40:01 +02:00
|
|
|
|
2020-08-31 00:50:54 +02:00
|
|
|
if (release == null)
|
2020-06-20 10:35:29 +02:00
|
|
|
{
|
2020-08-31 00:50:54 +02:00
|
|
|
throw new ArgumentNullException(nameof(release));
|
2020-06-20 10:35:29 +02:00
|
|
|
}
|
|
|
|
|
2020-08-31 00:50:54 +02:00
|
|
|
release.Chapters.Add(this);
|
2020-05-02 23:56:05 +02:00
|
|
|
}
|
2019-06-01 22:40:01 +02:00
|
|
|
|
2020-05-02 23:56:05 +02:00
|
|
|
/// <summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// Initializes a new instance of the <see cref="Chapter"/> class.
|
2020-05-02 23:56:05 +02:00
|
|
|
/// </summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// <remarks>
|
|
|
|
/// Default constructor. Protected due to required properties, but present because EF needs it.
|
|
|
|
/// </remarks>
|
|
|
|
protected Chapter()
|
2020-05-02 23:56:05 +02:00
|
|
|
{
|
|
|
|
}
|
2019-06-01 22:40:01 +02:00
|
|
|
|
2020-05-02 23:56:05 +02:00
|
|
|
/// <summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// Gets or sets the id.
|
2020-05-02 23:56:05 +02:00
|
|
|
/// </summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// <remarks>
|
2020-06-16 00:37:52 +02:00
|
|
|
/// Identity, Indexed, Required.
|
2020-08-31 00:50:54 +02:00
|
|
|
/// </remarks>
|
2020-05-02 23:56:05 +02:00
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
2020-08-31 00:50:54 +02:00
|
|
|
public int Id { get; protected set; }
|
2019-06-01 22:40:01 +02:00
|
|
|
|
2020-05-02 23:56:05 +02:00
|
|
|
/// <summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// Gets or sets the name.
|
2020-05-02 23:56:05 +02:00
|
|
|
/// </summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// <remarks>
|
|
|
|
/// Max length = 1024.
|
|
|
|
/// </remarks>
|
2020-05-02 23:56:05 +02:00
|
|
|
[MaxLength(1024)]
|
|
|
|
[StringLength(1024)]
|
2020-08-31 00:50:54 +02:00
|
|
|
public string Name { get; set; }
|
2019-06-01 22:40:01 +02:00
|
|
|
|
2020-05-02 23:56:05 +02:00
|
|
|
/// <summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// Gets or sets the language.
|
2020-05-02 23:56:05 +02:00
|
|
|
/// </summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// <remarks>
|
2020-05-02 23:56:05 +02:00
|
|
|
/// Required, Min length = 3, Max length = 3
|
2020-06-16 00:37:52 +02:00
|
|
|
/// ISO-639-3 3-character language codes.
|
2020-08-31 00:50:54 +02:00
|
|
|
/// </remarks>
|
2020-05-02 23:56:05 +02:00
|
|
|
[Required]
|
|
|
|
[MinLength(3)]
|
|
|
|
[MaxLength(3)]
|
|
|
|
[StringLength(3)]
|
2020-08-31 00:50:54 +02:00
|
|
|
public string Language { get; set; }
|
2020-06-15 23:43:52 +02:00
|
|
|
|
2020-05-02 23:56:05 +02:00
|
|
|
/// <summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// Gets or sets the start time.
|
2020-05-02 23:56:05 +02:00
|
|
|
/// </summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// <remarks>
|
2020-06-16 00:37:52 +02:00
|
|
|
/// Required.
|
2020-08-31 00:50:54 +02:00
|
|
|
/// </remarks>
|
|
|
|
public long StartTime { get; set; }
|
2019-06-01 22:40:01 +02:00
|
|
|
|
2020-05-02 23:56:05 +02:00
|
|
|
/// <summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
/// Gets or sets the end time.
|
2020-05-02 23:56:05 +02:00
|
|
|
/// </summary>
|
2020-08-31 00:50:54 +02:00
|
|
|
public long? EndTime { get; set; }
|
2020-05-02 23:56:05 +02:00
|
|
|
|
2020-08-31 00:50:54 +02:00
|
|
|
/// <inheritdoc />
|
2020-05-02 23:56:05 +02:00
|
|
|
[ConcurrencyCheck]
|
2020-08-31 00:50:54 +02:00
|
|
|
public uint RowVersion { get; protected set; }
|
2019-06-01 22:40:01 +02:00
|
|
|
|
2020-08-31 00:50:54 +02:00
|
|
|
/// <inheritdoc />
|
2020-05-02 23:56:05 +02:00
|
|
|
public void OnSavingChanges()
|
|
|
|
{
|
|
|
|
RowVersion++;
|
|
|
|
}
|
|
|
|
}
|
2019-06-01 22:40:01 +02:00
|
|
|
}
|