Files
itca_api_sap_wms/Net.Data/ServicesLayer/CreditNotes/CreditNotesRepository.cs
T
GeorgeandClaude Sonnet 5.5 e5ea57b673 Log del JSON enviado al Service Layer cuando SAP rechaza, para todos los documentos. Versión 2.1.5.0
Se mueve de CreditNotesRepository a ConnectionServiceLayer (PostAsync,
PatchAsyncSBA, PatchNoContentAsync) con un hook asignado en Startup.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 17:06:07 -05:00

93 lines
3.5 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Net.Business.Entities;
using Net.Business.Entities.ServicesLayer;
using Net.Business.Entities.ServicesLayer.CreditNotes;
using Net.Connection;
using Net.Connection.ServiceLayer;
using Net.CrossCotting;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Net.Data.ServicesLayer.CreditNotes
{
public class CreditNotesRepository : ICreditNotesRepository
{
#region Variables Globales
private string _aplicacionName;
private string _metodoName;
private readonly Regex regex = new Regex(@"<(\w+)>.*");
//Services Layer
private readonly ConnectionServiceLayer _connectServiceLayer;
private readonly IConnectionSQL _context;
#endregion
public CreditNotesRepository(IHttpClientFactory clientFactory, IConfiguration configuration, IConnectionSQL context)
{
_aplicacionName = this.GetType().Name;
_connectServiceLayer = new ConnectionServiceLayer(configuration, clientFactory);
_context = context;
}
public async Task<BE_ResultadoTransaccion<BE_BaseResponseSap>> SetCreateCreditNotes(BE_CreditNotesNotes entidad)
{
_metodoName = regex.Match(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name).Groups[1].Value.ToString();
ResultadoTransaccion<BE_BaseResponseSap> resultadoTransaccion = new ResultadoTransaccion<BE_BaseResponseSap>(_metodoName, _aplicacionName);
try
{
//var cadena = "Drafts";
var cadena = "CreditNotes";
var data = await _connectServiceLayer.PostAsync<BE_BaseResponseSap>(cadena, entidad);
if (!data.Exito)
{
return resultadoTransaccion.GetInformacionResultado(-1, -1, data.Mensaje);
}
return resultadoTransaccion.GetInformacionResultado(0, "", "Se Listo correctamento...!!!", data);
}
catch (Exception ex)
{
return resultadoTransaccion.GetInformacionResultado(-1, -1, ex.Message.ToString());
}
}
public async Task<BE_ResultadoTransaccion<BE_BaseResponseSap>> UpdateCreateCreditNotes(dynamic entidad, int DocEntry)
{
_metodoName = regex.Match(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name).Groups[1].Value.ToString();
ResultadoTransaccion<BE_BaseResponseSap> resultadoTransaccion = new ResultadoTransaccion<BE_BaseResponseSap>(_metodoName, _aplicacionName);
try
{
//var cadena = "Drafts";
var cadena = $"CreditNotes({DocEntry})";
var data = await _connectServiceLayer.PatchAsyncSBA<BE_BaseResponseSap>(cadena, entidad);
if (!data.Exito)
{
return resultadoTransaccion.GetInformacionResultado(-1, -1, data.Mensaje);
}
return resultadoTransaccion.GetInformacionResultado(0, "", "Se Listo correctamento...!!!", data);
}
catch (Exception ex)
{
return resultadoTransaccion.GetInformacionResultado(-1, -1, ex.Message.ToString());
}
}
}
}