using back.Application.Contracts.Persistence; using back.Application.Contracts.Services; using back.Application.Services; using back.Entities; using back.Entities.DTOs.Request; using back.Infra; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using System.Reflection; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly()); builder.Services.AddScoped, GenericService>(); builder.Services.AddScoped, GenericService>(); builder.Services.AddScoped, GenericService>(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped, BaseRepository>(); builder.Services.AddScoped, BaseRepository>(); builder.Services.AddScoped, BaseRepository>(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); var dbConnectionString = builder.Configuration.GetConnectionString("DefaultConnection"); builder.Services.AddDbContextFactory(options => { options.UseSqlServer(dbConnectionString); }); builder.Services.AddDbContext(options => options.UseSqlServer(dbConnectionString) .LogTo(Console.WriteLine, new[] { DbLoggerCategory.Database.Command.Name }, Microsoft.Extensions.Logging.LogLevel.Information) ); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();