Ajuste Correos
This commit is contained in:
parent
33b9913d72
commit
73400f442b
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using MSAdminUsuarios.Context;
|
using MSAdminUsuarios.Context;
|
||||||
|
using MSAdminUsuarios.Models;
|
||||||
using Security;
|
using Security;
|
||||||
|
|
||||||
namespace MSAdminUsuarios.Controllers
|
namespace MSAdminUsuarios.Controllers
|
||||||
@ -32,13 +33,15 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult post([FromBody] CORREOSAREAMS nuevo)
|
public IActionResult post([FromBody] CORREOSAREAMS nuevo)
|
||||||
{
|
{
|
||||||
|
ErrorModel _errorModel = new ErrorModel();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this._context.CORREOSAREAMS.Add(nuevo);
|
this._context.CORREOSAREAMS.Add(nuevo);
|
||||||
this._context.SaveChanges();
|
this._context.SaveChanges();
|
||||||
|
|
||||||
return Ok("Registro guardado correctamente.");
|
_errorModel.error = false;
|
||||||
|
_errorModel.cuerpo.Add("Registro guardado correctamente.");
|
||||||
|
return Ok(_errorModel);
|
||||||
|
|
||||||
} catch (Exception ex)
|
} catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -49,7 +52,7 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
[HttpPatch]
|
[HttpPatch]
|
||||||
public IActionResult patch([FromBody] CORREOSAREAMS actualizar)
|
public IActionResult patch([FromBody] CORREOSAREAMS actualizar)
|
||||||
{
|
{
|
||||||
|
ErrorModel _errorModel = new ErrorModel();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CORREOSAREAMS? existente = this._context.CORREOSAREAMS.FirstOrDefault(c => c.NU_PK_CRRMS == actualizar.NU_PK_CRRMS);
|
CORREOSAREAMS? existente = this._context.CORREOSAREAMS.FirstOrDefault(c => c.NU_PK_CRRMS == actualizar.NU_PK_CRRMS);
|
||||||
@ -58,9 +61,12 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
this._context.Entry(existente).CurrentValues.SetValues(actualizar);
|
this._context.Entry(existente).CurrentValues.SetValues(actualizar);
|
||||||
this._context.SaveChanges();
|
this._context.SaveChanges();
|
||||||
|
|
||||||
return Ok("Registro guardado correctamente.");
|
_errorModel.error = false;
|
||||||
|
_errorModel.cuerpo.Add("Registro actualizado correctamente.");
|
||||||
|
return Ok(_errorModel);
|
||||||
|
|
||||||
} catch (Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return BadRequest(ex.Message);
|
return BadRequest(ex.Message);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user