Exemplo n.º 1
0
        public static async Task <string> Confirmar(PedidoModel pedido)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    var uri = new Uri(URLAPI.Pedido() + "ConfirmarPedido");

                    var json = JsonConvert.SerializeObject(
                        new
                    {
                        Id_Pedido            = pedido.Id_Pedido,
                        Fecha                = pedido.Fecha,
                        Cliente              = pedido.Cliente,
                        TotalPedido          = pedido.TotalPedido,
                        Estado               = pedido.Estado,
                        Usuario_Confirmacion = pedido.Usuario_Confirmacion,
                        Usuario_Creacion     = pedido.Usuario_Creacion
                    }
                        );

                    var content = new StringContent(json, Encoding.UTF8, "application/json");

                    HttpResponseMessage response = client.PostAsync(uri, content).Result;
                    string resultado             = await response.Content.ReadAsStringAsync();

                    return(resultado);
                }
            }
            catch (WebException wex)
            {
                throw wex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public static async Task <PedidoModel> SeleccionarPorCodigo(string codigo)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    var uri = new Uri(URLAPI.Pedido() + "SeleccionarPedidosPorCodigo");

                    HttpResponseMessage response = client.GetAsync(uri).Result;
                    string resultado             = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <PedidoModel>(resultado));
                }
            }
            catch (WebException wex)
            {
                throw wex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public static async Task <ObservableCollection <PedidoModel> > SeleccionarTodos()
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    var uri = new Uri(URLAPI.Pedido() + "SeleccionarPedido");

                    HttpResponseMessage response = client.GetAsync(uri).Result;
                    string resultado             = await response.Content.ReadAsStringAsync();

                    return(new ObservableCollection <PedidoModel>(JsonConvert.DeserializeObject <PedidoModel[]>(resultado).ToList()));
                }
            }
            catch (WebException wex)
            {
                throw wex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public static async Task <string> Eliminar(string pedido)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    var uri = new Uri(URLAPI.Pedido() + "EliminarPedido?pedido=" + pedido);

                    HttpResponseMessage response = client.GetAsync(uri).Result;
                    string resultado             = await response.Content.ReadAsStringAsync();

                    return(resultado);
                }
            }
            catch (WebException wex)
            {
                throw wex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }