using Meezi.API.Models.Discover;
using Meezi.Core.Discover;
using Meezi.Infrastructure.Discover;

namespace Meezi.API.Services;

public static class CafeDiscoverProfileMapping
{
    public static CafeDiscoverProfileDto ToDto(CafeDiscoverProfile profile) =>
        new(
            profile.Themes,
            profile.Size,
            profile.Floors,
            profile.Vibes,
            profile.Occasions,
            profile.SpaceFeatures,
            profile.NoiseLevel,
            profile.PriceTier);

    public static CafeDiscoverProfile FromRequest(UpsertCafeDiscoverProfileRequest request) =>
        CafeDiscoverProfileSerializer.Sanitize(new CafeDiscoverProfile
        {
            Themes = request.Themes?.ToList() ?? [],
            Size = request.Size,
            Floors = request.Floors,
            Vibes = request.Vibes?.ToList() ?? [],
            Occasions = request.Occasions?.ToList() ?? [],
            SpaceFeatures = request.SpaceFeatures?.ToList() ?? [],
            NoiseLevel = request.NoiseLevel,
            PriceTier = request.PriceTier
        });

    public static DiscoverProfileTaxonomyDto Taxonomy() =>
        new(
            CafeDiscoverProfileKeys.Themes.OrderBy(x => x).ToList(),
            CafeDiscoverProfileKeys.Sizes.OrderBy(x => x).ToList(),
            CafeDiscoverProfileKeys.Floors.OrderBy(x => x).ToList(),
            CafeDiscoverProfileKeys.Vibes.OrderBy(x => x).ToList(),
            CafeDiscoverProfileKeys.Occasions.OrderBy(x => x).ToList(),
            CafeDiscoverProfileKeys.SpaceFeatures.OrderBy(x => x).ToList(),
            CafeDiscoverProfileKeys.NoiseLevels.OrderBy(x => x).ToList(),
            CafeDiscoverProfileKeys.PriceTiers.OrderBy(x => x).ToList());
}
