using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// An entity representing a genre.
///
public class Genre : IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The name.
/// The metadata.
public Genre(string name, Metadata metadata)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
Name = name;
if (metadata == null)
{
throw new ArgumentNullException(nameof(metadata));
}
metadata.Genres.Add(this);
}
///
/// Initializes a new instance of the class.
///
///
/// Default constructor. Protected due to required properties, but present because EF needs it.
///
protected Genre()
{
}
///
/// Gets or sets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
///
/// Gets or sets the name.
///
///
/// Indexed, Required, Max length = 255.
///
[Required]
[MaxLength(255)]
[StringLength(255)]
public string Name { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; protected set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}