Exemple #1
0
        //DELETE
        public async void deleteTask(Entity.Task myTask)
        {
            using (HttpClient client = new HttpClient()) {
                client.BaseAddress = new Uri(REST_BASE_URL);

                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Delete, REST_PATH + myTask.id);
                await client.SendAsync(request);
            }
        }
Exemple #2
0
 //PUT
 public async void updateTask(Entity.Task myTask)
 {
     myTask.createdAt = DateTime.Now.ToString("dd'-'MM'-'yyyy HH:mm:ss");
     using (HttpClient client = new HttpClient()) {
         client.BaseAddress = new Uri(REST_BASE_URL);
         HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, REST_PATH + myTask.id);
         request.Content = new StringContent(myTask.SerializeToDoTask(), Encoding.UTF8, "application/json");
         await client.SendAsync(request);
     }
 }
Exemple #3
0
 //POST
 public async void postTask(Entity.Task myTask)
 {
     using (HttpClient client = new HttpClient()) {
         client.BaseAddress = new Uri(REST_BASE_URL);
         client.DefaultRequestHeaders
         .Accept
         .Add(new MediaTypeWithQualityHeaderValue("application/json"));
         HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, REST_PATH);
         request.Content = new StringContent(myTask.SerializeToDoTask(), Encoding.UTF8, "application/json");
         await client.SendAsync(request);
     }
 }