2023-02-02 10:50:02 -05:00
|
|
|
|
using MSAdminUsuarios.Context;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace MSAdminUsuarios.Controllers
|
|
|
|
|
{
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("[controller]")]
|
|
|
|
|
public class MicroserviciosController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly ModelContext _context;
|
|
|
|
|
|
|
|
|
|
public MicroserviciosController(ModelContext context)
|
|
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public async Task<IActionResult> GetMicroservicios()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
/*var consulta = from dm in _context.MICROSERVICIOs
|
|
|
|
|
select dm;*/
|
2024-07-15 08:01:51 -05:00
|
|
|
|
List<MICROSERVICIO> microservicios = await _context.MICROSERVICIOs.OrderBy(m => m.NU_PK_MS).ToListAsync();
|
2023-02-02 10:50:02 -05:00
|
|
|
|
return Ok(microservicios);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<IActionResult> GuardarPerfiles(MICROSERVICIO guardado)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (guardado == null) return ValidationProblem();
|
|
|
|
|
|
|
|
|
|
_context.MICROSERVICIOs.Add(guardado);
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
return Ok();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|