Se creó un nuevo controlador para los correos por area
This commit is contained in:
parent
719616920e
commit
5ed791d372
13
Microservicios/MsUsuarios/Context/CorreosArea.cs
Normal file
13
Microservicios/MsUsuarios/Context/CorreosArea.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace MSAdminUsuarios.Context
|
||||
{
|
||||
public class CorreosArea
|
||||
{
|
||||
public int NU_PK_CORA { get; set; }
|
||||
public int? NU_MODULO_CORA { get; set; }
|
||||
public int? NU_AREA_CORA { get; set; }
|
||||
public int? NU_SEDE_CORA { get; set; }
|
||||
public int? BL_ESTADO_CORA { get; set; }
|
||||
public string? TX_FKDOC_USUMS { get; set; }
|
||||
public string? TX_CORREOS_CORA { get; set; }
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ namespace MSAdminUsuarios.Context
|
||||
public virtual DbSet<PERFIL> PERFILESMs { get; set; } = null!;
|
||||
public virtual DbSet<PERFILPORUSUARIO> PERFILESPORUSUARIOs { get; set; } = null!;
|
||||
public virtual DbSet<USUARIO> USUARIOSMs { get; set; } = null!;
|
||||
public virtual DbSet<CorreosArea> CORREOSAREAMS { get; set; } = null!;
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
@ -79,6 +80,14 @@ namespace MSAdminUsuarios.Context
|
||||
entity.Property(e => e.CL_FIRMA_USUMS).HasColumnType("CLOB");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CorreosArea>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.NU_PK_CORA);
|
||||
|
||||
entity.ToTable("CORREOSAREAMS");
|
||||
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,69 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MSAdminUsuarios.Context;
|
||||
using Security;
|
||||
|
||||
namespace MSAdminUsuarios.Controllers
|
||||
{
|
||||
[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class CorreosAreaController : ControllerBase
|
||||
{
|
||||
private readonly ModelContext _context;
|
||||
public CorreosAreaController(ModelContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult obtener()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<CorreosArea> lista = this._context.CORREOSAREAMS.ToList();
|
||||
|
||||
return Ok(lista);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult post([FromBody] CorreosArea nuevo)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
this._context.CORREOSAREAMS.Add(nuevo);
|
||||
this._context.SaveChanges();
|
||||
|
||||
return Ok("Registro guardado correctamente.");
|
||||
|
||||
} catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPatch]
|
||||
public IActionResult patch([FromBody] CorreosArea actualizar)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
CorreosArea? existente = this._context.CORREOSAREAMS.FirstOrDefault(c => c.NU_PK_CORA == actualizar.NU_PK_CORA);
|
||||
if (existente == null) return BadRequest("Registro inexistente");
|
||||
|
||||
this._context.Entry(existente).CurrentValues.SetValues(actualizar);
|
||||
this._context.SaveChanges();
|
||||
|
||||
return Ok("Registro guardado correctamente.");
|
||||
|
||||
} catch (Exception ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user