public static async Task <bool> UpdEstoque(EstoqueL _estoque) { LoadClient(); try { string uri = _base_path + "/api/v1/estoque"; var json = JsonConvert.SerializeObject(_estoque); var stringContent = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = await _client.PutAsync(new Uri(uri), stringContent); var property = response.GetType().GetProperty("StatusCode"); if ((HttpStatusCode)property.GetValue(response) == HttpStatusCode.OK) { response.EnsureSuccessStatusCode(); _message = "HttpStatus.200"; return(true); } if ((HttpStatusCode)property.GetValue(response) == HttpStatusCode.BadRequest) { _message = "HttpStatus.400"; return(false); } if ((HttpStatusCode)property.GetValue(response) == HttpStatusCode.InternalServerError) { _message = "HttpStatus.500"; return(false); } } catch (Exception e) { _message = e.Message; } return(false); }
public static string GetJsonEstoque(EstoqueL _item) { return(JsonConvert.SerializeObject(_item)); }