using System.Collections.Generic; using System.Linq; using Kyoo.Models.Attributes; using Newtonsoft.Json; namespace Kyoo.Models { public class Library { [JsonIgnore] public int ID { get; set; } public string Slug { get; set; } public string Name { get; set; } public IEnumerable Paths { get; set; } public IEnumerable Providers { get => ProviderLinks?.Select(x => x.Provider); set => ProviderLinks = value.Select(x => new ProviderLink(x, this)).ToList(); } [NotMergable] [JsonIgnore] public virtual IEnumerable ProviderLinks { get; set; } [NotMergable] [JsonIgnore] public virtual IEnumerable Links { get; set; } [JsonIgnore] public IEnumerable Shows { get => Links?.Where(x => x.Show != null).Select(x => x.Show); set => Links = Utility.MergeLists( value?.Select(x => new LibraryLink(this, x)), Links?.Where(x => x.Show == null)); } [JsonIgnore] public IEnumerable Collections { get => Links?.Where(x => x.Collection != null).Select(x => x.Collection); set => Links = Utility.MergeLists( value?.Select(x => new LibraryLink(this, x)), Links?.Where(x => x.Collection == null)); } public Library() { } public Library(string slug, string name, IEnumerable paths, IEnumerable providers) { Slug = slug; Name = name; Paths = paths; Providers = providers; } } }