public static async Task <bool> PutRichting(Richting c) { try { using (HttpClient client = new HttpClient()) { var json = JsonConvert.SerializeObject(c); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PutAsync(string.Concat(API_URL + "Richtingen/" + c.RichtingID), content); if (response.IsSuccessStatusCode) { return(true); } else { throw new WebException("An error has occurred while calling PutCampus method: " + response.Content); } } } catch (WebException exception) { throw new WebException("An error has occurred while calling PutCampus method: " + exception.Message); } }
public static async Task <Richting> GetRichting(int id) { Richting campus = null; try { using (HttpClient client = new HttpClient()) { HttpResponseMessage data = await client.GetAsync(string.Concat(API_URL, "Richtingen/", id)); String json = await data.Content.ReadAsStringAsync(); if (json != null) { campus = JsonConvert.DeserializeObject <Richting>(json); } return(campus); } } catch (Exception e) { throw e; } }