//using Modules.Library.Database.Database.Models;
//using Modules.Library.Database.Database.Models.Anime;
//using Modules.Library.Database.Database.Models.CommonProperties;
//using MongoDB.Bson;

//namespace Modules.Library.Database.Repositories.Converters;

//internal static class ToDbConverter
//{
//    internal static AnimeTitle1 Title(Domain.Entities.MediaContent.Items.Anime.AnimeTitle entity)
//    {
//        var result = new AnimeTitle1
//        {
//            CommonProperties = ToDbConverter.CommonProperties(entity.CommonProperties),
//            Items = entity.Items.Select(q =>
//            {
//                AnimeItem1 result;
//                if (q is Domain.Entities.MediaContent.Items.Anime.AnimeSeason season) result = Season(season);
//                else if (q is Domain.Entities.MediaContent.Items.Anime.AnimeEpisode episode) result = Episode(episode);
//                else throw new NotImplementedException();
//                return result;
//            }).ToList(),
//            Completed = entity.Completed,
//            ExpirationTime = entity.ExpirationTime,
//        };
//        ToDbConverterBase.SetId(result, entity.Id);
//        result.SetDeleted(entity.Deleted);
//        return result;
//    }

//    internal static AnimeSeasonq Season(Domain.Entities.MediaContent.Items.Anime.AnimeSeason entity)
//    {
//        var result = new AnimeSeasonq
//        {
//            CommonProperties = ToDbConverter.CommonProperties(entity.CommonProperties),
//            Episodes = entity.Episodes.Select(Episode).ToList(),
//            Number = entity.Number,
//            Order = entity.Order,
//            Variant = entity.Variant,
//            OriginCountry = entity.OriginCountry,
//            Completed = entity.Completed,
//            Director = entity.Director,
//            ExpirationTime = entity.ExpirationTime,
//        };
//        ToDbConverterBase.SetId(result, entity.Id);
//        result.SetDeleted(entity.Deleted);
//        return result;
//    }

//    internal static AnimeEpisode1 Episode(Domain.Entities.MediaContent.Items.Anime.AnimeEpisode entity)
//    {
//        var result = new AnimeEpisode1
//        {
//            CommonProperties = ToDbConverter.CommonProperties(entity.CommonProperties),
//            Type = (AnimeEpisodeType1)entity.Type,
//            Order = entity.Order,
//            Variant = entity.Variant,
//            Completed = entity.Completed,
//            Number = entity.Number,
//            ExpirationTime = entity.ExpirationTime,
//        };
//        ToDbConverterBase.SetId(result, entity.Id);
//        result.SetDeleted(entity.Deleted);
//        return result;
//    }

//    internal static CommonProperties1 CommonProperties(Domain.Entities.MediaContent.CommonProperties.CommonProperties entity)
//    {
//        var result = new CommonProperties1
//        {
//            Names = entity.Names.Select(NameItem).ToList(),
//            Preview = entity.Preview != null ? MediaInfo(entity.Preview) : null,
//            Descriptions = entity.Descriptions.Select(Description).ToList(),
//            Genres = entity.Genres.Select(Genre).ToList(),
//            RelatedContent = entity.RelatedContent.Select(MediaInfo).ToList(),
//            AnnouncementDate = entity.AnnouncementDate,
//            EstimatedReleaseDate = entity.EstimatedReleaseDate,
//            ReleaseDate = entity.ReleaseDate,
//        };
//        SetId(result, entity.Id);
//        result.SetDeleted(entity.Deleted);
//        return result;
//    }

//    //internal static NameItem NameItem(Domain.Entities.MediaContent.CommonProperties.NameItem entity, bool createNew)
//    internal static NameItem1 NameItem(Domain.Entities.MediaContent.CommonProperties.NameItem entity)
//    {
//        var result = new NameItem1
//        {
//            LanguageId = entity.LanguageId,
//            Type = (NameType1)entity.Type,
//            Value = entity.Value,
//        };
//        SetId(result, entity.Id);
//        result.SetDeleted(entity.Deleted);
//        return result;
//    }

//    //internal static MediaInfo NameItem(Domain.Entities.MediaInfo entity, bool createNew)
//    internal static MediaInfo1 MediaInfo(Domain.Entities.MediaInfo entity)
//    {
//        var result = new MediaInfo1
//        {
//            Type = (MediaInfoType1)entity.Type,
//            Url = entity.Url,
//        };
//        SetId(result, entity.Id);
//        result.SetDeleted(entity.Deleted);
//        return result;
//    }

//    internal static DescriptionItem1 Description(Domain.Entities.MediaContent.CommonProperties.DescriptionItem entity)
//    {
//        var result = new DescriptionItem1
//        {
//            LanguageId = entity.LanguageId,
//            IsOriginal = entity.IsOriginal,
//            Value = entity.Value,
//        };
//        SetId(result, entity.Id);
//        result.SetDeleted(entity.Deleted);
//        return result;
//    }

//    internal static GenreProportionItem1 Genre(Domain.Entities.MediaContent.CommonProperties.GenreProportionItem entity)
//    {
//        var result = new GenreProportionItem1
//        {
//            GenreId = entity.GenreId,
//            Proportion = entity.Proportion,
//        };
//        SetId(result, entity.Id);
//        result.SetDeleted(entity.Deleted);
//        return result;
//    }

//    internal static void SetId(Entity1 entity, string? domainEntityId = null)
//    {
//        if (string.IsNullOrWhiteSpace(domainEntityId)) entity.ObjectId = ObjectId.GenerateNewId();
//        else entity.ObjectId = ObjectId.Parse(domainEntityId);
//    }

//}