Beispiel #1
0
        public static async Task <bool> GetPedido(int _id = 0)
        {
            LoadClient();

            try
            {
                string uri = _base_path + "/api/v1/pedidos/" + _id.ToString();
                HttpResponseMessage response = await _client.GetAsync(uri);

                var property = response.GetType().GetProperty("StatusCode");
                if ((HttpStatusCode)property.GetValue(response) == HttpStatusCode.OK)
                {
                    response.EnsureSuccessStatusCode();
                    DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(PedidoL));
                    _pedido = (PedidoL)jsonSerializer.ReadObject(await response.Content.ReadAsStreamAsync());
                    return(true);
                }
            }
            catch (Exception e)
            {
                _message = e.Message;
            }
            return(false);
        }
Beispiel #2
0
 public static string GetJsonPedido(PedidoL _item)
 {
     return(JsonConvert.SerializeObject(_item));
 }