using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// An entity representing a person.
///
public class Person : IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The name of the person.
public Person(string name)
{
ArgumentException.ThrowIfNullOrEmpty(name);
Name = name;
DateAdded = DateTime.UtcNow;
DateModified = DateAdded;
Sources = new HashSet();
}
///
/// Gets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
///
/// Gets or sets the name.
///
///
/// Required, Max length = 1024.
///
[MaxLength(1024)]
[StringLength(1024)]
public string Name { get; set; }
///
/// Gets or sets the source id.
///
///
/// Max length = 255.
///
[MaxLength(256)]
[StringLength(256)]
public string? SourceId { get; set; }
///
/// Gets the date added.
///
///
/// Required.
///
public DateTime DateAdded { get; private set; }
///
/// Gets or sets the date modified.
///
///
/// Required.
///
public DateTime DateModified { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; private set; }
///
/// Gets a list of metadata sources for this person.
///
public virtual ICollection Sources { get; private set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}