using Microsoft.Extensions.Logging;
using FWLAZData;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using Microsoft.Maui.Controls;

namespace FWLAZ
{
    public static class MauiProgram
    {
        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                });
            //builder.Configuration.AddJsonFile("appsettings.json", false, true);

            //var connectionString = builder.Configuration.GetConnectionString("LocalDB");
            //if (connectionString != null) LocalDbContext.SetConnectionString(connectionString);
            builder.Services.AddDbContextFactory<LocalDbContext>();
            builder.Services.AddMauiBlazorWebView();

#if DEBUG
            builder.Services.AddBlazorWebViewDeveloperTools();
            builder.Logging.AddDebug();
#endif
            DBManagement.ConnectAndMigrate();


            return builder.Build();
        }
    }
}
