using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data.Entities.Libraries
{
    /// 
    /// An entity representing a library item.
    /// 
    public abstract class LibraryItem : IHasConcurrencyToken
    {
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// The library of this item.
        protected LibraryItem(Library library)
        {
            DateAdded = DateTime.UtcNow;
            Library = library;
        }
        /// 
        /// Gets the id.
        /// 
        /// 
        /// Identity, Indexed, Required.
        /// 
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; private set; }
        /// 
        /// Gets the date this library item was added.
        /// 
        public DateTime DateAdded { get; private set; }
        /// 
        [ConcurrencyCheck]
        public uint RowVersion { get; private set; }
        /// 
        /// Gets or sets the library of this item.
        /// 
        /// 
        /// Required.
        /// 
        public virtual Library Library { get; set; }
        /// 
        public void OnSavingChanges()
        {
            RowVersion++;
        }
    }
}