Fix: Quita Archivos de DB Unificadas Sobrantes

This commit is contained in:
2026-02-13 12:01:18 -03:00
parent ed243ccb78
commit 9a2b5a5f91
5 changed files with 0 additions and 357 deletions

View File

@@ -1,85 +0,0 @@
using Microsoft.EntityFrameworkCore;
using MotoresArgentinosV2.Core.DTOs;
using MotoresArgentinosV2.Core.Entities;
namespace MotoresArgentinosV2.Infrastructure.Data;
/// <summary>
/// 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 EldiaDbContext : DbContext
{
public EldiaDbContext(DbContextOptions<EldiaDbContext> options) : base(options)
{
}
// Tablas de la base 'autos' (ahora en eldia)
public DbSet<Operacion> Operaciones { get; set; }
public DbSet<MedioDePago> MediosDePago { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// --- Configuración de tablas ex-Autos ---
modelBuilder.Entity<Operacion>(entity =>
{
entity.ToTable("operaciones");
entity.HasKey(e => e.Id);
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Fecha).HasColumnName("fecha");
entity.Property(e => e.Motivo).HasColumnName("motivo").HasMaxLength(50);
entity.Property(e => e.Moneda).HasColumnName("moneda").HasMaxLength(50);
entity.Property(e => e.Direccionentrega).HasColumnName("direccionentrega").HasMaxLength(50);
entity.Property(e => e.Validaciondomicilio).HasColumnName("validaciondomicilio").HasMaxLength(50);
entity.Property(e => e.Codigopedido).HasColumnName("codigopedido").HasMaxLength(50);
entity.Property(e => e.Nombreentrega).HasColumnName("nombreentrega").HasMaxLength(50);
entity.Property(e => e.Fechahora).HasColumnName("fechahora").HasMaxLength(50);
entity.Property(e => e.Telefonocomprador).HasColumnName("telefonocomprador").HasMaxLength(50);
entity.Property(e => e.Barrioentrega).HasColumnName("barrioentrega").HasMaxLength(50);
entity.Property(e => e.Codautorizacion).HasColumnName("codautorizacion").HasMaxLength(50);
entity.Property(e => e.Paisentrega).HasColumnName("paisentrega").HasMaxLength(50);
entity.Property(e => e.Cuotas).HasColumnName("cuotas").HasMaxLength(50);
entity.Property(e => e.Validafechanac).HasColumnName("validafechanac").HasMaxLength(50);
entity.Property(e => e.Validanrodoc).HasColumnName("validanrodoc").HasMaxLength(50);
entity.Property(e => e.Titular).HasColumnName("titular").HasMaxLength(50);
entity.Property(e => e.Pedido).HasColumnName("pedido").HasMaxLength(50);
entity.Property(e => e.Zipentrega).HasColumnName("zipentrega").HasMaxLength(50);
entity.Property(e => e.Monto).HasColumnName("monto").HasMaxLength(50);
entity.Property(e => e.Tarjeta).HasColumnName("tarjeta").HasMaxLength(50);
entity.Property(e => e.Fechaentrega).HasColumnName("fechaentrega").HasMaxLength(50);
entity.Property(e => e.Emailcomprador).HasColumnName("emailcomprador").HasMaxLength(50);
entity.Property(e => e.Validanropuerta).HasColumnName("validanropuerta").HasMaxLength(50);
entity.Property(e => e.Ciudadentrega).HasColumnName("ciudadentrega").HasMaxLength(50);
entity.Property(e => e.Validatipodoc).HasColumnName("validatipodoc").HasMaxLength(50);
entity.Property(e => e.Noperacion).HasColumnName("noperacion").HasMaxLength(50);
entity.Property(e => e.Estadoentrega).HasColumnName("estadoentrega").HasMaxLength(50);
entity.Property(e => e.Resultado).HasColumnName("resultado").HasMaxLength(50);
entity.Property(e => e.Mensajeentrega).HasColumnName("mensajeentrega").HasMaxLength(50);
entity.Property(e => e.Precioneto).HasColumnName("precioneto");
});
modelBuilder.Entity<MedioDePago>(entity =>
{
entity.ToTable("mediodepago");
entity.HasKey(e => e.Id);
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,111 +0,0 @@
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using MotoresArgentinosV2.Core.Entities;
using MotoresArgentinosV2.Core.Interfaces;
using MotoresArgentinosV2.Infrastructure.Data;
namespace MotoresArgentinosV2.Infrastructure.Services;
/// <summary>
/// Implementación del servicio para interactuar con datos legacy de operaciones
/// Utiliza EldiaDbContext para acceder a tablas y ejecutar SPs de la DB 'eldia' (ex base de datos 'autos')
/// </summary>
public class OperacionesLegacyService : IOperacionesLegacyService
{
private readonly EldiaDbContext _context;
private readonly ILogger<OperacionesLegacyService> _logger;
public OperacionesLegacyService(EldiaDbContext context, ILogger<OperacionesLegacyService> logger)
{
_context = context;
_logger = logger;
}
/// <summary>
/// Ejecuta el SP sp_inserta_operaciones para registrar un pago
/// </summary>
public async Task<bool> InsertarOperacionAsync(Operacion operacion)
{
try
{
_logger.LogInformation("Ejecutando sp_inserta_operaciones para operación: {Noperacion}", operacion.Noperacion);
// Preparar parámetros asegurando manejo de nulos
var parameters = new[]
{
new SqlParameter("@fecha", operacion.Fecha ?? (object)DBNull.Value),
new SqlParameter("@Motivo", operacion.Motivo ?? (object)DBNull.Value),
new SqlParameter("@Moneda", operacion.Moneda ?? (object)DBNull.Value),
new SqlParameter("@Direccionentrega", operacion.Direccionentrega ?? (object)DBNull.Value),
new SqlParameter("@Validaciondomicilio", operacion.Validaciondomicilio ?? (object)DBNull.Value),
new SqlParameter("@codigopedido", operacion.Codigopedido ?? (object)DBNull.Value),
new SqlParameter("@nombreentrega", operacion.Nombreentrega ?? (object)DBNull.Value),
new SqlParameter("@fechahora", operacion.Fechahora ?? (object)DBNull.Value),
new SqlParameter("@telefonocomprador", operacion.Telefonocomprador ?? (object)DBNull.Value),
new SqlParameter("@barrioentrega", operacion.Barrioentrega ?? (object)DBNull.Value),
new SqlParameter("@codautorizacion", operacion.Codautorizacion ?? (object)DBNull.Value),
new SqlParameter("@paisentrega", operacion.Paisentrega ?? (object)DBNull.Value),
new SqlParameter("@cuotas", operacion.Cuotas ?? (object)DBNull.Value),
new SqlParameter("@validafechanac", operacion.Validafechanac ?? (object)DBNull.Value),
new SqlParameter("@validanrodoc", operacion.Validanrodoc ?? (object)DBNull.Value),
new SqlParameter("@titular", operacion.Titular ?? (object)DBNull.Value),
new SqlParameter("@pedido", operacion.Pedido ?? (object)DBNull.Value),
new SqlParameter("@zipentrega", operacion.Zipentrega ?? (object)DBNull.Value),
new SqlParameter("@monto", operacion.Monto ?? (object)DBNull.Value),
new SqlParameter("@tarjeta", operacion.Tarjeta ?? (object)DBNull.Value),
new SqlParameter("@fechaentrega", operacion.Fechaentrega ?? (object)DBNull.Value),
new SqlParameter("@emailcomprador", operacion.Emailcomprador ?? (object)DBNull.Value),
new SqlParameter("@validanropuerta", operacion.Validanropuerta ?? (object)DBNull.Value),
new SqlParameter("@ciudadentrega", operacion.Ciudadentrega ?? (object)DBNull.Value),
new SqlParameter("@validatipodoc", operacion.Validatipodoc ?? (object)DBNull.Value),
new SqlParameter("@noperacion", operacion.Noperacion ?? (object)DBNull.Value),
new SqlParameter("@estadoentrega", operacion.Estadoentrega ?? (object)DBNull.Value),
new SqlParameter("@resultado", operacion.Resultado ?? (object)DBNull.Value),
new SqlParameter("@mensajeentrega", operacion.Mensajeentrega ?? (object)DBNull.Value),
new SqlParameter("@precio", operacion.Precioneto ?? 0) // El SP espera int
};
await _context.Database.ExecuteSqlRawAsync(
"EXEC dbo.sp_inserta_operaciones @fecha, @Motivo, @Moneda, @Direccionentrega, " +
"@Validaciondomicilio, @codigopedido, @nombreentrega, @fechahora, @telefonocomprador, " +
"@barrioentrega, @codautorizacion, @paisentrega, @cuotas, @validafechanac, @validanrodoc, " +
"@titular, @pedido, @zipentrega, @monto, @tarjeta, @fechaentrega, @emailcomprador, " +
"@validanropuerta, @ciudadentrega, @validatipodoc, @noperacion, @estadoentrega, " +
"@resultado, @mensajeentrega, @precio",
parameters);
_logger.LogInformation("Operación registrada correctamente: {Noperacion}", operacion.Noperacion);
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Error al insertar operación: {Noperacion}", operacion.Noperacion);
throw;
}
}
public async Task<List<Operacion>> ObtenerOperacionesPorNumeroAsync(string noperacion)
{
return await _context.Operaciones
.AsNoTracking()
.Where(o => o.Noperacion == noperacion)
.ToListAsync();
}
public async Task<List<Operacion>> ObtenerOperacionesPorFechasAsync(DateTime fechaInicio, DateTime fechaFin)
{
return await _context.Operaciones
.AsNoTracking()
.Where(o => o.Fecha >= fechaInicio && o.Fecha <= fechaFin)
.OrderByDescending(o => o.Fecha)
.ToListAsync();
}
public async Task<List<MedioDePago>> ObtenerMediosDePagoAsync()
{
return await _context.MediosDePago
.AsNoTracking()
.ToListAsync();
}
}