Feat Gestion de Fuentes URLs

This commit is contained in:
2025-11-21 11:20:44 -03:00
parent 1a46f15ec1
commit 2e353cbb8c
9 changed files with 832 additions and 77 deletions

View File

@@ -86,5 +86,65 @@ namespace ChatbotApi.Controllers
.ToListAsync();
return Ok(logs);
}
// ENDPOINTS PARA FUENTES DE CONTEXTO (URLs)
[HttpGet("fuentes")]
public async Task<IActionResult> GetAllFuentes()
{
var fuentes = await _context.FuentesDeContexto.OrderBy(f => f.Nombre).ToListAsync();
return Ok(fuentes);
}
[HttpPost("fuentes")]
public async Task<IActionResult> CreateFuente([FromBody] FuenteContexto fuente)
{
_context.FuentesDeContexto.Add(fuente);
await _context.SaveChangesAsync();
return CreatedAtAction(nameof(GetAllFuentes), new { id = fuente.Id }, fuente);
}
[HttpPut("fuentes/{id}")]
public async Task<IActionResult> UpdateFuente(int id, [FromBody] FuenteContexto fuente)
{
if (id != fuente.Id)
{
return BadRequest();
}
_context.Entry(fuente).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!_context.FuentesDeContexto.Any(e => e.Id == id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
[HttpDelete("fuentes/{id}")]
public async Task<IActionResult> DeleteFuente(int id)
{
var fuente = await _context.FuentesDeContexto.FindAsync(id);
if (fuente == null)
{
return NotFound();
}
_context.FuentesDeContexto.Remove(fuente);
await _context.SaveChangesAsync();
return NoContent();
}
}
}