Exemplo n.º 1
0
        public static async Task <bool> GetProduto(int _id = 0)
        {
            LoadClient();

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

                var property = response.GetType().GetProperty("StatusCode");
                if ((HttpStatusCode)property.GetValue(response) == HttpStatusCode.OK)
                {
                    response.EnsureSuccessStatusCode();
                    var json = new DataContractJsonSerializer(typeof(ProdutoL));
                    _produto = (ProdutoL)json.ReadObject(await response.Content.ReadAsStreamAsync());
                    return(true);
                }
            }
            catch (Exception e)
            {
                _message = e.Message;
            }
            return(false);
        }
Exemplo n.º 2
0
 public static string GetJsonProduto(ProdutoL _item)
 {
     return(JsonConvert.SerializeObject(_item));
 }