Feat: Reforma de unificación de bases de datos.

This commit is contained in:
2026-01-30 10:29:35 -03:00
parent 7b89859dcf
commit 32cf2ba74a
8 changed files with 35 additions and 68 deletions

View File

@@ -1,35 +1,29 @@
using Microsoft.EntityFrameworkCore;
using MotoresArgentinosV2.Core.DTOs;
using MotoresArgentinosV2.Core.Entities;
namespace MotoresArgentinosV2.Infrastructure.Data;
/// <summary>
/// Contexto de Entity Framework para la base de datos Autos (legacy)
/// Servidor: TECNICA3
/// Base de Datos: autos
/// Propósito: Acceso a operaciones de pago y medios de pago
/// Contexto de Entity Framework unificado para la base de datos 'eldia' (Legacy)
/// Contiene las tablas de avisos web, operaciones, medios de pago y lógica de usuarios legacy.
/// </summary>
public class AutosDbContext : DbContext
public class EldiaDbContext : DbContext
{
public AutosDbContext(DbContextOptions<AutosDbContext> options) : base(options)
public EldiaDbContext(DbContextOptions<EldiaDbContext> options) : base(options)
{
}
/// <summary>
/// Tabla de operaciones de pago
/// </summary>
// Tablas de la base 'autos' (ahora en eldia)
public DbSet<Operacion> Operaciones { get; set; }
/// <summary>
/// Tabla de medios de pago disponibles
/// </summary>
public DbSet<MedioDePago> MediosDePago { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// Configuración para la tabla operaciones
// --- Configuración de tablas ex-Autos ---
modelBuilder.Entity<Operacion>(entity =>
{
entity.ToTable("operaciones");
@@ -67,7 +61,6 @@ public class AutosDbContext : DbContext
entity.Property(e => e.Precioneto).HasColumnName("precioneto");
});
// Configuración para la tabla mediodepago
modelBuilder.Entity<MedioDePago>(entity =>
{
entity.ToTable("mediodepago");
@@ -75,5 +68,18 @@ public class AutosDbContext : DbContext
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Mediodepago).HasColumnName("mediodepago").HasMaxLength(20);
});
// --- Configuración de DTOs Keyless de ex-Internet ---
modelBuilder.Entity<DatosAvisoDto>(e =>
{
e.HasNoKey();
e.ToView(null);
e.Property(p => p.ImporteSiniva).HasColumnType("decimal(18,2)");
e.Property(p => p.ImporteTotsiniva).HasColumnType("decimal(18,2)");
e.Property(p => p.PorcentajeCombinado).HasColumnType("decimal(18,2)");
e.Property(p => p.Centimetros).HasColumnType("decimal(18,2)");
});
}
}

View File

@@ -1,36 +0,0 @@
// Backend/MotoresArgentinosV2.Infrastructure/Data/InternetDbContext.cs
using Microsoft.EntityFrameworkCore;
using MotoresArgentinosV2.Core.DTOs;
namespace MotoresArgentinosV2.Infrastructure.Data;
/// <summary>
/// Contexto de Entity Framework para la base de datos Internet (legacy)
/// Servidor: ...
/// Base de Datos: internet
/// Propósito: Acceso a datos de avisos web
/// </summary>
public class InternetDbContext : DbContext
{
public InternetDbContext(DbContextOptions<InternetDbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// Registrar el DTO como entidad sin llave (Keyless) para que SqlQueryRaw funcione bien
modelBuilder.Entity<DatosAvisoDto>(e =>
{
e.HasNoKey();
e.ToView(null); // No mapea a tabla
// Configurar precisión de decimales para silenciar warnings
e.Property(p => p.ImporteSiniva).HasColumnType("decimal(18,2)");
e.Property(p => p.ImporteTotsiniva).HasColumnType("decimal(18,2)");
e.Property(p => p.PorcentajeCombinado).HasColumnType("decimal(18,2)");
e.Property(p => p.Centimetros).HasColumnType("decimal(18,2)");
});
}
}