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 library item.
        public CollectionItem(LibraryItem libraryItem)
        {
            LibraryItem = libraryItem;
        }
        /// 
        /// Gets or sets the id.
        /// 
        /// 
        /// Identity, Indexed, Required.
        /// 
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }
        /// 
        [ConcurrencyCheck]
        public uint RowVersion { get; private 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++;
        }
    }
}