100 lines
4.0 KiB
C#
100 lines
4.0 KiB
C#
using Microsoft.Extensions.Configuration;
|
|||
|
|
using Net.Business.Entities;
|
||
|
|
using Net.Business.Entities.ServicesLayer;
|
||
|
|
using Net.Connection.ServiceLayer;
|
||
|
|
using Net.CrossCotting;
|
||
|
|
using System;
|
||
|
|
using System.Net.Http;
|
||
|
|
using System.Text.RegularExpressions;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
|
||
|
|
namespace Net.Data.ServicesLayer.StockTransfer
|
||
|
|
{
|
||
|
|
public class StockTransferRepository: IStockTransferRepository
|
||
|
|
{
|
||
|
|
#region Variables Globales
|
||
|
|
|
||
|
|
private string _aplicacionName;
|
||
|
|
private string _metodoName;
|
||
|
|
private readonly Regex regex = new Regex(@"<(\w+)>.*");
|
||
|
|
|
||
|
|
//Services Layer
|
||
|
|
private readonly ConnectionServiceLayer _connectServiceLayer;
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
public StockTransferRepository(IHttpClientFactory clientFactory, IConfiguration configuration)
|
||
|
|
{
|
||
|
|
_aplicacionName = this.GetType().Name;
|
||
|
|
_connectServiceLayer = new ConnectionServiceLayer(configuration, clientFactory);
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task<BE_ResultadoTransaccion<BE_BaseResponseSap>> StockTransfer(dynamic 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 = "StockTransfers";
|
||
|
|
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>> CloseInventoryTransferRequest(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 = $"InventoryTransferRequests({DocEntry})/Close";
|
||
|
|
var data = await _connectServiceLayer.PostClose<BE_BaseResponseSap>(cadena);
|
||
|
|
|
||
|
|
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>> GetInventoryTransferRequest(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 = $"InventoryTransferRequests({DocEntry})";
|
||
|
|
var data = await _connectServiceLayer.GetAsync<BE_BaseResponseSap>(cadena, 0, true);
|
||
|
|
|
||
|
|
return resultadoTransaccion.GetInformacionResultado(0, 0, "Se Listo correctamento...!!!", data);
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
return resultadoTransaccion.GetInformacionResultado(-1, -1, ex.Message.ToString());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|