76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
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<IBaseService<Persona, PersonaRequestDto, PersonaUpdateRequestDto>, GenericService<Persona, PersonaRequestDto, PersonaUpdateRequestDto>>();
|
|
builder.Services.AddScoped<IBaseService<Casa, CasaRequestDto, CasaUpdateRequestDto>, GenericService<Casa, CasaRequestDto, CasaUpdateRequestDto>>();
|
|
builder.Services.AddScoped<IBaseService<Direccion, DireccionRequestDto, DireccionUpdateRequestDto>, GenericService<Direccion, DireccionRequestDto, DireccionUpdateRequestDto>>();
|
|
|
|
builder.Services.AddScoped<CasaService>();
|
|
builder.Services.AddScoped<PersonaService>();
|
|
builder.Services.AddScoped<DireccionService>();
|
|
builder.Services.AddScoped<IWantItAllService, WantItAllService>();
|
|
|
|
builder.Services.AddScoped<IAsyncRepository<Persona>, BaseRepository<Persona>>();
|
|
builder.Services.AddScoped<IAsyncRepository<Casa>, BaseRepository<Casa>>();
|
|
builder.Services.AddScoped<IAsyncRepository<Direccion>, BaseRepository<Direccion>>();
|
|
|
|
builder.Services.AddScoped<PersonaRepository>();
|
|
builder.Services.AddScoped<CasaRepository>();
|
|
builder.Services.AddScoped<DireccionRepository>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dbConnectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
|
|
|
builder.Services.AddDbContextFactory<Application_Db_Context>(options =>
|
|
{
|
|
options.UseSqlServer(dbConnectionString);
|
|
});
|
|
|
|
builder.Services.AddDbContext<Application_Db_Context>(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();
|