public static ServiceReferenceDLL.cDllPedido TomarPedidoConIdCarrito(int pIdCarrito, string pLoginCliente, string pIdSucursal, string pMensajeEnFactura, string pMensajeEnRemito, string pTipoEnvio, List <ServiceReferenceDLL.cDllProductosAndCantidad> pListaProducto, bool pIsUrgente) { try { capaCAR.InicioCarritoEnProceso(pIdCarrito, Constantes.cAccionCarrito_TOMAR); if (isCore) { List <DKbase.dll.cDllProductosAndCantidad> l_Productos = Codigo.clases.Generales.Serializador.DeserializarJson <List <DKbase.dll.cDllProductosAndCantidad> >(Codigo.clases.Generales.Serializador.SerializarAJson(pListaProducto)); var t = Task.Run(() => capaCore_WebService.TomarPedidoConIdCarritoAsync(pIdCarrito, pLoginCliente, pIdSucursal, pMensajeEnFactura, pMensajeEnRemito, pTipoEnvio, l_Productos, pIsUrgente)); t.Wait(); if (t.Result == null) { throw new Exception("Result == null"); } DKbase.dll.cDllPedido objResult = t.Result; return(Codigo.clases.Generales.Serializador.DeserializarJson <ServiceReferenceDLL.cDllPedido>(Codigo.clases.Generales.Serializador.SerializarAJson(objResult))); } else { return(capaWebServiceDLL.TomarPedidoConIdCarrito(pIdCarrito, pLoginCliente, pIdSucursal, pMensajeEnFactura, pMensajeEnRemito, pTipoEnvio, pListaProducto, pIsUrgente)); } } catch (Exception ex) { FuncionesPersonalizadas.grabarLog(MethodBase.GetCurrentMethod(), ex, DateTime.Now, pIdCarrito, pLoginCliente, pIdSucursal, pMensajeEnFactura, pMensajeEnRemito, pTipoEnvio, pListaProducto, pIsUrgente); return(null); } finally { capaCAR.EndCarritoEnProceso(pIdCarrito); } }
//public static async Task<DKbase.dll.cDllPedido> TomarPedidoConIdCarritoAsync_Get(int pIdCarrito, string pLoginCliente, string pIdSucursal, string pMensajeEnFactura, string pMensajeEnRemito, string pTipoEnvio, List<DKbase.dll.cDllProductosAndCantidad> pListaProducto, bool pIsUrgente) //{ // try // { // string name = "TomarPedidoConIdCarrito"; // string url_api = url + name; // capaCAR.InicioCarritoEnProceso(pIdCarrito, Constantes.cAccionCarrito_TOMAR); // DKbase.dll.cDllPedido product = null; // HttpResponseMessage response = await client.GetAsync(url_api); // if (response.IsSuccessStatusCode) // { // string data = await response.Content.ReadAsStringAsync(); // product = JsonSerializer.Deserialize<DKbase.dll.cDllPedido>(data); // } // return product; // } // catch (Exception ex) // { // FuncionesPersonalizadas.grabarLog(MethodBase.GetCurrentMethod(), ex, DateTime.Now, pIdCarrito, pLoginCliente, pIdSucursal, pMensajeEnFactura, pMensajeEnRemito, pTipoEnvio, pListaProducto, pIsUrgente); // return null; // } // finally // { // capaCAR.EndCarritoEnProceso(pIdCarrito); // } //} // public static async Task <DKbase.dll.cDllPedido> TomarPedidoConIdCarritoAsync(int pIdCarrito, string pLoginCliente, string pIdSucursal, string pMensajeEnFactura, string pMensajeEnRemito, string pTipoEnvio, List <DKbase.dll.cDllProductosAndCantidad> pListaProducto, bool pIsUrgente) { DKbase.dll.cDllPedido result = null; string name = "TomarPedidoConIdCarrito"; DKbase.Models.TomarPedidoConIdCarritoRequest parameter = new DKbase.Models.TomarPedidoConIdCarritoRequest() { pIdCarrito = pIdCarrito, pLoginCliente = pLoginCliente, pIdSucursal = pIdSucursal, pMensajeEnFactura = pMensajeEnFactura, pMensajeEnRemito = pMensajeEnRemito, pTipoEnvio = pTipoEnvio, pListaProducto = pListaProducto, pIsUrgente = pIsUrgente }; HttpResponseMessage response = await PostAsync(name, parameter); if (response != null) { var resultResponse = response.Content.ReadAsStringAsync().Result; result = JsonSerializer.Deserialize <DKbase.dll.cDllPedido>(resultResponse, oJsonSerializerOptions); } return(result); }