Exemplo n.º 1
0
        static async Task <Uri> CriarAnotacaoAsync(Anotacao anotacao)
        {
            HttpResponseMessage response = await client.PostAsJsonAsync(
                "api/products", anotacao);

            response.EnsureSuccessStatusCode();

            // return URI of the created resource.
            return(response.Headers.Location);
        }
Exemplo n.º 2
0
        public static async Task <Anotacao> SelecionarAnotacaoAsync(string path)
        {
            Anotacao            anotacao = null;
            HttpResponseMessage response = await client.GetAsync(path);

            if (response.IsSuccessStatusCode)
            {
                anotacao = await response.Content.ReadAsAsync <Anotacao>();
            }
            return(anotacao);
        }
Exemplo n.º 3
0
        static async Task <Anotacao> AtualizarAnotacaoAsync(Anotacao anotacao)
        {
            HttpResponseMessage response = await client.PutAsJsonAsync(
                $"api/products/{anotacao.Cod}", anotacao);

            response.EnsureSuccessStatusCode();

            // Deserialize the updated product from the response body.
            anotacao = await response.Content.ReadAsAsync <Anotacao>();

            return(anotacao);
        }
Exemplo n.º 4
0
 static void MostrarAnotacao(Anotacao anotacao)
 {
     Console.WriteLine($"Cod: {anotacao.Cod}\tConteúdo: " +
                       $"{anotacao.Conteudo}\tHorário: {anotacao.Horario}");
 }