Commit inicial: ITCA_API_SAP_WMS (.NET Core 3.1)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
2b82744eb8
168 files changed
+11066
No files matched your search
@@ -0,0 +1,100 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Business.DTO.WMS.SolicitudTransferencia;
|
||||
using Net.Business.Entities;
|
||||
using Net.Business.Services.Log;
|
||||
using Net.Data;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services.Controllers
|
||||
{
|
||||
// Modulo 100% nuevo (sin equivalente en el .NET original) - ver
|
||||
// docs/SOLICITUD_TRANSFERENCIA.md para el contrato completo.
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||||
[Authorize(AuthenticationSchemes = "Bearer")]
|
||||
public class SolicitudTransferenciaController : ControllerBase
|
||||
{
|
||||
private readonly IRepositoryWrapper _repository;
|
||||
public SolicitudTransferenciaController(IRepositoryWrapper repository)
|
||||
{
|
||||
this._repository = repository;
|
||||
}
|
||||
|
||||
// Responde 200 con el BE_ResultadoTransaccion completo en vez de 204 -
|
||||
// decision deliberada: un 204 no puede llevar body (RFC 7231 §6.3.5) y
|
||||
// muchos clientes HTTP, incluido HttpClient de .NET, no lo leen si el
|
||||
// status es 204 - ver docs/SOLICITUD_TRANSFERENCIA.md.
|
||||
[HttpPatch]
|
||||
[Route("{docEntry}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> Patch(int docEntry, [FromBody] Dto_SolicitudTransferenciaPatchRequest value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Master object is null"), "SolicitudTraslado", "0", docEntry.ToString(), "0", "0");
|
||||
return BadRequest("Master object is null");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Invalid model object"), "SolicitudTraslado", value.NumOrden, docEntry.ToString(), "0", "0");
|
||||
return BadRequest("Invalid model object");
|
||||
}
|
||||
|
||||
var error = await _repository.SolicitudTransferencia.Update(docEntry, value.RetornaModelo());
|
||||
|
||||
var result = error ?? new BE_ResultadoTransaccion<object>
|
||||
{
|
||||
DocEntry = docEntry,
|
||||
StatusCode = 200,
|
||||
Message = "Registrado Correctamente",
|
||||
AppName = "SolicitudTransferenciaRepository",
|
||||
MethodName = "Update",
|
||||
Data = value,
|
||||
};
|
||||
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(result)), "SolicitudTraslado", value.NumOrden, docEntry.ToString(), result.DocNum, result.DocEntry?.ToString());
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("{docEntry}/cerrar")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> Cerrar(int docEntry)
|
||||
{
|
||||
var error = await _repository.SolicitudTransferencia.Cerrar(docEntry);
|
||||
|
||||
var result = error ?? new BE_ResultadoTransaccion<object>
|
||||
{
|
||||
DocEntry = docEntry,
|
||||
StatusCode = 200,
|
||||
Message = "Cerrado Correctamente",
|
||||
AppName = "SolicitudTransferenciaRepository",
|
||||
MethodName = "Cerrar",
|
||||
};
|
||||
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { docEntry })), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(result)), "SolicitudTraslado", "0", docEntry.ToString(), result.DocNum, result.DocEntry?.ToString());
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user