using Microsoft.Extensions.Configuration; using Net.Business.Entities; using Net.Business.Entities.ServicesLayer; using Net.Business.Entities.ServicesLayer.PurchaseDeliveryNotes; using Net.Connection.ServiceLayer; using Net.CrossCotting; using System; using System.Collections.Generic; using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Net.Data.ServicesLayer { public class PurchaseDeliveryNotesRepository : IPurchaseDeliveryNotesRepository { #region Variables Globales private string _aplicacionName; private string _metodoName; private readonly Regex regex = new Regex(@"<(\w+)>.*"); //Services Layer private readonly ConnectionServiceLayer _connectServiceLayer; #endregion public PurchaseDeliveryNotesRepository(IHttpClientFactory clientFactory, IConfiguration configuration) { _aplicacionName = this.GetType().Name; _connectServiceLayer = new ConnectionServiceLayer(configuration, clientFactory); } public async Task> SetCreatePurchaseDeliveryNotes(BE_PurchaseDeliveryNotes entidad) { _metodoName = regex.Match(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name).Groups[1].Value.ToString(); ResultadoTransaccion resultadoTransaccion = new ResultadoTransaccion(_metodoName, _aplicacionName); try { var cadena = "PurchaseDeliveryNotes"; var data = await _connectServiceLayer.PostAsync(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()); } } // GET INVOICES public async Task> GetPurchaseDeliveryNotes(int docEntry) { _metodoName = regex.Match(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name).Groups[1].Value.ToString(); ResultadoTransaccion resultadoTransaccion = new ResultadoTransaccion(_metodoName, _aplicacionName); try { string cadena = $"PurchaseDeliveryNotes({docEntry})"; int maxpagesize = 0; List objectList = await _connectServiceLayer.GetAsync(cadena, maxpagesize, true); return resultadoTransaccion.GetInformacionResultado(0, 0, "Se Listo correctamento...!!!", objectList); } catch (Exception ex) { return resultadoTransaccion.GetInformacionResultado(-1, -1, ex.Message.ToString()); } } } }