using BootstrapBlazor.Components;
using BootstrapBlazorApp11.Server.Data;
using Microsoft.Extensions.Localization;
namespace BootstrapBlazorApp11.Server.Service;

public class LookupService(ICacheManager cacheManager, IStringLocalizer<Foo> localizer) : ILookupService
{
    public IEnumerable<SelectedItem>? GetItemsByKey(string? key)
    {
        return null;
    }

    public IEnumerable<SelectedItem>? GetItemsByKey(string? key, object? data)
    {
        return key switch
        {
            "Country" => new List<SelectedItem> { new SelectedItem("中国", "中国"), new SelectedItem("美国", "美国"), new SelectedItem("日本", "日本") },
            _ => null
        };

    }

    public Task<IEnumerable<SelectedItem>?> GetItemsByKeyAsync(string? key, object? data)
    {
        return null;
        //return key switch
        //{
        //    "inCustomer" => cacheManager.GetOrCreate("inCustomer", entry =>
        //    {
        //        entry.AbsoluteExpiration = DateTime.Now.AddHours(2);
        //        return inininService.GetInCustomerAsync();
        //    }),
        //    _ => Task.FromResult<IEnumerable<SelectedItem>?>(new List<SelectedItem>()),
        //};
    }
}
