Init Commit
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MotoresArgentinosV2.Core.DTOs;
|
||||
using MotoresArgentinosV2.Core.Interfaces;
|
||||
|
||||
namespace MotoresArgentinosV2.API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AvisosLegacyController : ControllerBase
|
||||
{
|
||||
private readonly IAvisosLegacyService _avisosService;
|
||||
private readonly ILogger<AvisosLegacyController> _logger;
|
||||
|
||||
public AvisosLegacyController(IAvisosLegacyService avisosService, ILogger<AvisosLegacyController> logger)
|
||||
{
|
||||
_avisosService = avisosService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obtiene las tarifas y configuración de avisos según la tarea y paquete
|
||||
/// </summary>
|
||||
/// <param name="tarea">Tipo de tarea (ej: EMOTORES, EAUTOS)</param>
|
||||
/// <param name="paquete">ID del paquete (opcional, default 0)</param>
|
||||
[HttpGet("configuracion")]
|
||||
public async Task<ActionResult<List<DatosAvisoDto>>> GetConfiguracion([FromQuery] string tarea, [FromQuery] int paquete = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(tarea))
|
||||
{
|
||||
return BadRequest("El parámetro 'tarea' es obligatorio.");
|
||||
}
|
||||
|
||||
var resultados = await _avisosService.ObtenerDatosAvisosAsync(tarea, paquete);
|
||||
return Ok(resultados);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error al obtener configuración de avisos");
|
||||
return StatusCode(500, "Ocurrió un error interno al procesar la solicitud.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Crea un nuevo aviso en el sistema legacy
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<bool>> CrearAviso([FromBody] InsertarAvisoDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
var resultado = await _avisosService.InsertarAvisoAsync(dto);
|
||||
|
||||
if (resultado)
|
||||
{
|
||||
return CreatedAtAction(nameof(CrearAviso), true);
|
||||
}
|
||||
|
||||
return BadRequest("No se pudo crear el aviso.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error al crear aviso para cliente {IdCliente}", dto.IdCliente);
|
||||
return StatusCode(500, "Ocurrió un error interno al crear el aviso.");
|
||||
}
|
||||
}
|
||||
[HttpGet("cliente/{nroDoc}")]
|
||||
public async Task<ActionResult<List<AvisoWebDto>>> GetAvisosPorCliente(string nroDoc)
|
||||
{
|
||||
var avisos = await _avisosService.ObtenerAvisosPorClienteAsync(nroDoc);
|
||||
return Ok(avisos);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user