using System;
using System.Collections.Generic;
using API.Entities.Enums;
using API.Entities.Interfaces;
namespace API.Entities;
public class Library : IEntityDate
{
public int Id { get; set; }
public required string Name { get; set; }
public string? CoverImage { get; set; }
public LibraryType Type { get; set; }
///
/// If Folder Watching is enabled for this library
///
public bool FolderWatching { get; set; } = true;
///
/// Include Library series on Dashboard Streams
///
public bool IncludeInDashboard { get; set; } = true;
///
/// Include Library series on Recommended Streams
///
public bool IncludeInRecommended { get; set; } = true;
///
/// Include library series in Search
///
public bool IncludeInSearch { get; set; } = true;
///
/// Should this library create collections from Metadata
///
public bool ManageCollections { get; set; } = true;
///
/// Should this library create reading lists from Metadata
///
public bool ManageReadingLists { get; set; } = true;
///
/// Should this library allow Scrobble events to emit from it
///
/// Scrobbling requires a valid LicenseKey
public bool AllowScrobbling { get; set; } = true;
public DateTime Created { get; set; }
public DateTime LastModified { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime LastModifiedUtc { get; set; }
///
/// Last time Library was scanned
///
/// Time stored in UTC
public DateTime LastScanned { get; set; }
public ICollection Folders { get; set; } = null!;
public ICollection AppUsers { get; set; } = null!;
public ICollection Series { get; set; } = null!;
public ICollection LibraryFileTypes { get; set; } = new List();
public ICollection LibraryExcludePatterns { get; set; } = new List();
public void UpdateLastModified()
{
LastModified = DateTime.Now;
LastModifiedUtc = DateTime.UtcNow;
}
public void UpdateLastScanned(DateTime? time)
{
if (time == null)
{
LastScanned = DateTime.Now;
}
else
{
LastScanned = (DateTime) time;
}
}
}