2dfe7daa2c
- ContratoService + ContratoController (CRUD, PDF data, empresa, firma) - CotizacionService + CotizacionController (CRUD, detalle, pago, empresa) - AlumnoService + AlumnoController (CRUD, apoderado, consultas, colegios) - InformeService + InformeController (reportes ventas, leads, documentos) - All services registered in DI (Program.cs)
86 lines
3.5 KiB
C#
86 lines
3.5 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Ventas.Services;
|
|
|
|
namespace Ventas.API.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
[Authorize]
|
|
public class ContratoController : ControllerBase
|
|
{
|
|
private readonly ContratoService _contratoService;
|
|
|
|
public ContratoController(ContratoService contratoService)
|
|
{
|
|
_contratoService = contratoService;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Ingresar([FromQuery] int cotizacionId, [FromQuery] string fechaContrato, [FromQuery] int boletaId, [FromQuery] int vendedorId)
|
|
{
|
|
var result = await _contratoService.IngresarAsync(cotizacionId, fechaContrato, boletaId, vendedorId);
|
|
return Ok(new { id = result });
|
|
}
|
|
|
|
[HttpPost("detalle")]
|
|
public async Task<IActionResult> IngresarDetalle([FromQuery] int contratoId, [FromQuery] string empresaId, [FromQuery] string alumnoId, [FromQuery] string cursoId, [FromQuery] string fecha, [FromQuery] int vendedor, [FromQuery] int registroAcademico, [FromQuery] int alumnoTipo)
|
|
{
|
|
var result = await _contratoService.IngresarDetalleAsync(contratoId, empresaId, alumnoId, cursoId, fecha, vendedor, registroAcademico, alumnoTipo);
|
|
return Ok(new { id = result });
|
|
}
|
|
|
|
[HttpGet("{id}/pdf")]
|
|
public async Task<IActionResult> PdfContrato(int id)
|
|
{
|
|
var data = await _contratoService.PdfContratoAsync(id);
|
|
var jornadas = await _contratoService.PdfContratoJornadasAsync(id);
|
|
var programas = await _contratoService.PdfContratoProgramasCursosAsync(id);
|
|
var sedes = await _contratoService.PdfContratoSedesAsync(id);
|
|
|
|
return Ok(new { data, jornadas, programas, sedes });
|
|
}
|
|
|
|
[HttpGet("{id}")]
|
|
public async Task<IActionResult> BuscarInformacion(int id)
|
|
{
|
|
var result = await _contratoService.BuscarInformacionAsync(id);
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpPost("empresa")]
|
|
public async Task<IActionResult> IngresarContratoEmpresa([FromQuery] int cotizacionId, [FromQuery] string empresaId, [FromQuery] int tipoVenta, [FromQuery] int facturaId, [FromQuery] int cantCursos, [FromQuery] int vendedorId)
|
|
{
|
|
var result = await _contratoService.IngresarContratoEmpresaAsync(cotizacionId, empresaId, tipoVenta, facturaId, cantCursos, vendedorId);
|
|
return Ok(new { id = result });
|
|
}
|
|
|
|
[HttpPost("cerrado")]
|
|
public async Task<IActionResult> IngresarContratoCerrado([FromQuery] int prop, [FromQuery] string rut, [FromQuery] int tipoVenta, [FromQuery] string vendedorId)
|
|
{
|
|
var result = await _contratoService.IngresarContratoCerradoAsync(prop, rut, tipoVenta, vendedorId);
|
|
return Ok(new { id = result });
|
|
}
|
|
|
|
[HttpPost("{id}/firma")]
|
|
public async Task<IActionResult> IngresarFirmaPendiente(int id)
|
|
{
|
|
var result = await _contratoService.IngresarFirmaPendienteAsync(id);
|
|
return Ok(new { mensaje = result });
|
|
}
|
|
|
|
[HttpPut("{id}/estado")]
|
|
public async Task<IActionResult> ActualizarEstado(int id, [FromQuery] string tipo, [FromQuery] string varA, [FromQuery] int varB)
|
|
{
|
|
var result = await _contratoService.ActualizarEstadoContratoAsync(tipo, id, varA, varB);
|
|
return Ok(new { mensaje = result });
|
|
}
|
|
|
|
[HttpPut("{id}/firma")]
|
|
public async Task<IActionResult> ActualizarFirma(int id, [FromQuery] string tipo, [FromQuery] int firmado)
|
|
{
|
|
var result = await _contratoService.ActualizarFirmaContratoAsync(tipo, id, firmado);
|
|
return Ok(new { mensaje = result });
|
|
}
|
|
}
|