using BarBusinessLogic.BusinessLogics;
using BarContracts.BusinessLogicContracts;
using BarContracts.StoragesContracts;
using BarDatabaseImplement.Implements;
using Microsoft.OpenApi.Models;

var Builder = WebApplication.CreateBuilder(args);
Builder.Logging.SetMinimumLevel(LogLevel.Trace);
Builder.Logging.AddLog4Net("log4net.config");

// Add services to the container.
Builder.Services.AddTransient<IClientStorage, ClientStorage>();
Builder.Services.AddTransient<IOrderStorage, OrderStorage>();
Builder.Services.AddTransient<ICocktailStorage, CocktailStorage>();
Builder.Services.AddTransient<IOrderLogic, OrderLogic>();
Builder.Services.AddTransient<IClientLogic, ClientLogic>();
Builder.Services.AddTransient<ICocktailLogic, CocktailLogic>();
Builder.Services.AddControllers();

Builder.Services.AddEndpointsApiExplorer();
Builder.Services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1", new OpenApiInfo
    {
        Title = "BarRestApi",
        Version = "v1"
    });
});

var App = Builder.Build();

if (App.Environment.IsDevelopment())
{
    App.UseSwagger();
    App.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
   "BarRestApi v1"));
}

App.UseHttpsRedirection();
App.UseAuthorization();
App.MapControllers();

App.Run();
