using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
///
/// An entity representing a collection item.
///
public class CollectionItem : IHasConcurrencyToken
{
///
/// Initializes a new instance of the class.
///
/// The collection.
/// The previous item.
/// The next item.
public CollectionItem(Collection collection, CollectionItem previous, CollectionItem next)
{
if (collection == null)
{
throw new ArgumentNullException(nameof(collection));
}
collection.Items.Add(this);
if (next != null)
{
Next = next;
next.Previous = this;
}
if (previous != null)
{
Previous = previous;
previous.Next = this;
}
}
///
/// Initializes a new instance of the class.
///
///
/// Default constructor. Protected due to required properties, but present because EF needs it.
///
protected CollectionItem()
{
}
///
/// Gets or sets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
///
[ConcurrencyCheck]
public uint RowVersion { get; set; }
///
/// Gets or sets the library item.
///
///
/// Required.
///
public virtual LibraryItem LibraryItem { get; set; }
///
/// Gets or sets the next item in the collection.
///
///
/// TODO check if this properly updated dependant and has the proper principal relationship
///
public virtual CollectionItem Next { get; set; }
///
/// Gets or sets the previous item in the collection.
///
///
/// TODO check if this properly updated dependant and has the proper principal relationship
///
public virtual CollectionItem Previous { get; set; }
///
public void OnSavingChanges()
{
RowVersion++;
}
}
}