//using Modules.Library.Database.Database.Models.Anime;
//using Modules.Library.Database.Repositories;

//namespace Modules.Library.Application.Queries.Converters;

//internal class AnimeTitleConverter
//{
//    private readonly CommonPropertiesConverter _commonPropertiesConverter;
//    private readonly AnimeSeasonConverter _animeSeasonConverter;
//    private readonly AnimeEpisodeConverter _animeEpisodeConverter;

//    internal AnimeTitleConverter(LanguageRepository languageRepository, GenreRepository genreRepository)
//    {
//        _commonPropertiesConverter = new CommonPropertiesConverter(languageRepository, genreRepository);
//        _animeSeasonConverter = new AnimeSeasonConverter(_commonPropertiesConverter);
//        _animeEpisodeConverter = new AnimeEpisodeConverter(_commonPropertiesConverter);
//    }
//    /*
//    internal async Task<Domain.Entities.MediaContent.Items.Anime.AnimeTitle> Convert(AnimeTitle title)
//    {
//        var titleBuilder = new AnimeTitleBuilder();
//        titleBuilder.SetCommonProperties(await _commonPropertiesConverter.GetBuilder(title.CommonProperties))
//            .SetExpirationTime(title.ExpirationTime);
//        if (title.Deleted) titleBuilder.Deleted();
//        if (title.Completed) titleBuilder.Completed();
//        if (!title.IsTransient()) titleBuilder.SetId(title.Id);
//        foreach (var season in title.Items.OfType<AnimeSeason>())
//        {
//            titleBuilder.AddSeason(await _animeSeasonConverter.GetBuilder(season));
//        }
//        foreach (var episode in title.Items.OfType<AnimeEpisode>())
//        {
//            titleBuilder.AddEpisode(await _animeEpisodeConverter.GetBuilder(episode));
//        }

//        /*
//        var dbTitle = new Domain.Entities.MediaContent.Items.Anime.AnimeTitle
//        {
//            CommonProperties = new CommonProperties
//            {
//                Names = title.CommonProperties.Names.Select(q => new NameItem
//                {
//                    Value = q.Value,
//                    Type = (NameType)q.Type,
//                    LanguageId = q.LanguageId,
//                }).ToList(),
//                Preview = title.CommonProperties.Preview == null ? null : new MediaInfo
//                {
//                    //Id = 
//                    Type = (MediaInfoType)title.CommonProperties.Preview.Type,
//                    Url = title.CommonProperties.Preview.Url,
//                },
//                Descriptions = title.CommonProperties.Descriptions.Select(q => new DescriptionItem
//                {
//                    IsOriginal = q.IsOriginal,
//                    Value = q.Value,
//                }).ToList(),
//                Genres = title.CommonProperties.Genres.Select(q => new GenreProportionItem
//                {
//                    GenreId = q.Genre.Id,
//                    Proportion = q.Proportion,
//                }).ToList(),
//                RelatedContent = title.CommonProperties.RelatedContent.Select(q => new MediaInfo
//                {
//                    Type = (MediaInfoType)q.Type,
//                    Url = q.Url,
//                }).ToList(),
//                AnnouncementDate = title.CommonProperties.AnnouncementDate,
//                EstimatedReleaseDate = title.CommonProperties.EstimatedReleaseDate,
//                ReleaseDate = title.CommonProperties.ReleaseDate,
//            },
//            Completed = title.Completed,
//            Deleted = title.Deleted,
//            ExpirationTime = title.ExpirationTime,
//        };
//        */
//    /*
//        return titleBuilder.Build();
//    }
//    */
//    internal async Task<Domain.Entities.MediaContent.Items.Anime.AnimeTitle> Convert(AnimeTitle title)
//    {
//        var dto = new Domain.Models.AnimeTitle
//        {
//            Id = title.Id,
//            Deleted = title.Deleted,
//            Completed = title.Completed,
//            CommonProperties = await _commonPropertiesConverter.Convert(title.CommonProperties),
//            ExpirationTime = title.ExpirationTime,
//        };
//        foreach (var season in title.Items.OfType<AnimeSeason>())
//        {
//            dto.Items.Add(await _animeSeasonConverter.Convert(season));
//        }
//        foreach (var episode in title.Items.OfType<AnimeEpisode>())
//        {
//            dto.Items.Add(await _animeEpisodeConverter.Convert(episode));
//        }
//        return Domain.Entities.MediaContent.Items.Anime.AnimeTitle.New(dto);
//    }

//    internal AnimeTitle Convert(Domain.Entities.MediaContent.Items.Anime.AnimeTitle title)
//    {
//        var dbTitle = new AnimeTitle
//        {
//            Id = title.Id,
//            CommonProperties = _commonPropertiesConverter.Convert(title.CommonProperties),
//            Completed = title.Completed,
//            Deleted = title.Deleted,
//            ExpirationTime = title.ExpirationTime,
//        };
//        if (!title.IsTransient()) dbTitle.Id = title.Id;
//        foreach (var season in title.Items.OfType<Domain.Entities.MediaContent.Items.Anime.AnimeSeason>())
//        {
//            dbTitle.Items.Add(_animeSeasonConverter.Convert(season));
//        }
//        foreach (var episode in title.Items.OfType<Domain.Entities.MediaContent.Items.Anime.AnimeEpisode>())
//        {
//            dbTitle.Items.Add(_animeEpisodeConverter.Convert(episode));
//        }
//        return dbTitle;

//    }
//}