c1e35445f6
- Added Ejecutivo.cs entity - ArqueoService + ArqueoController (arqueos por fecha/usuario) - 13 missing controllers: Curso, Descuento, Documento, Empresa, Horario, Jornada, Programa, Propuesta, Region, Sala, Sede, Tarifa, Usuario - JwtMiddleware.cs for cookie/token validation - SpComplexQueries.cs for Dapper multi-resultset - ArqueoService registered in DI - Build: 0 errors - Total: 21 controllers, 8 services, 7 repos, 21 entities
50 lines
2.0 KiB
C#
50 lines
2.0 KiB
C#
using Dapper;
|
|
using Npgsql;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Ventas.API.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
[Authorize]
|
|
public class DescuentoController : ControllerBase
|
|
{
|
|
private readonly string _connectionString;
|
|
|
|
public DescuentoController(IConfiguration configuration)
|
|
{
|
|
_connectionString = configuration.GetConnectionString("Default")!;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> Buscar([FromQuery] string tipoBusqueda, [FromQuery] int sede, [FromQuery] int programa, [FromQuery] int horario)
|
|
{
|
|
using var connection = new NpgsqlConnection(_connectionString);
|
|
var rows = await connection.QueryAsync("sige_sam_v3.BuscarDescuentos",
|
|
new { tipobusqueda = tipoBusqueda, sedeid = sede, programaid = programa, horarioid = horario },
|
|
commandType: System.Data.CommandType.StoredProcedure);
|
|
return Ok(rows.Select(r => (Dictionary<string, object>)(IDictionary<string, object>)r!));
|
|
}
|
|
|
|
[HttpGet("summer")]
|
|
public async Task<IActionResult> Summer([FromQuery] int cantidadCursos)
|
|
{
|
|
using var connection = new NpgsqlConnection(_connectionString);
|
|
var rows = await connection.QueryAsync("sige_sam_v3.BuscarDesctoSummer",
|
|
new { cantidad = cantidadCursos },
|
|
commandType: System.Data.CommandType.StoredProcedure);
|
|
return Ok(rows.Select(r => (Dictionary<string, object>)(IDictionary<string, object>)r!));
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Ingresar([FromQuery] int cotizacionId, [FromQuery] int descuentoId, [FromQuery] int tipoDescuento, [FromQuery] int nuevoMonto)
|
|
{
|
|
using var connection = new NpgsqlConnection(_connectionString);
|
|
await connection.ExecuteAsync("sige_sam_v3.DescuentoCotizacion",
|
|
new { cotiid = cotizacionId, desctoid = descuentoId, tipoid = tipoDescuento, nuevototal = nuevoMonto },
|
|
commandType: System.Data.CommandType.StoredProcedure);
|
|
return Ok(new { mensaje = "ok" });
|
|
}
|
|
}
|