55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
![]() |
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;*/
|
|||
|
List<MICROSERVICIO> microservicios = await _context.MICROSERVICIOs.OrderBy(m => m.TX_SECCION_MS).ToListAsync();
|
|||
|
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|