fix: complete repository layer and refactor services
- Added ContratoRepository, CotizacionRepository, AlumnoRepository, UsuarioRepository (Infrastructure) - Added IInformeRepository + InformeRepository for report SPs - Refactored ContratoService, CotizacionService, AlumnoService, UsuarioService to use repos via DI - Refactored InformeService, EmpresaReportService to use IInformeRepository - Updated Program.cs DI to wire repos correctly with connection string factory - Build: 0 errors
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Dapper;
|
||||
using Npgsql;
|
||||
using Ventas.Core.Interfaces;
|
||||
|
||||
namespace Ventas.Infrastructure.Repositories;
|
||||
|
||||
public class CotizacionRepository : ICotizacionRepository
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
|
||||
public CotizacionRepository(string connectionString)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
}
|
||||
|
||||
public async Task<string> PersonaIngresarAsync(string apoderado, string vendedor, int solicitudDescuento, int descuento, int tipoDescuento, string fecha, int alumnos, int curso, int monto, string validez, int leadId)
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString);
|
||||
return await connection.QuerySingleOrDefaultAsync<string>(
|
||||
"sige_sam_v3.IngresarCotizacionLead",
|
||||
new { apoderado, vendedor, solicituddescuento = solicitudDescuento, desctoid = descuento, tipodesctoid = tipoDescuento, fecha, alumno = alumnos, cantidad = curso, monto, validez, leadnum = leadId },
|
||||
commandType: System.Data.CommandType.StoredProcedure) ?? "ok";
|
||||
}
|
||||
|
||||
public async Task<string> PersonaPagarAsync(int cotizacionId)
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString);
|
||||
await connection.ExecuteAsync(
|
||||
"sige_sam_v3.PagarCotizacion",
|
||||
new { cotizacionid = cotizacionId },
|
||||
commandType: System.Data.CommandType.StoredProcedure);
|
||||
return "ok";
|
||||
}
|
||||
|
||||
public async Task<string> DesactivarAsync(int cotizacionId)
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString);
|
||||
await connection.ExecuteAsync(
|
||||
"sige_sam_v3.DesactivarCotizacion",
|
||||
new { cotizacionid = cotizacionId },
|
||||
commandType: System.Data.CommandType.StoredProcedure);
|
||||
return "ok";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user