public async Task <bool> DeleteTrip(int id) { _httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Bearer", StorageService.RetrieveToken()); var json = await _httpClient.DeleteAsync(new Uri($"{Globals.BASE_URL}/Trip/{id}")); return(JsonConvert.DeserializeObject <bool>(await json.Content.ReadAsStringAsync())); }
public async Task <Trip> UpsertTrip(Trip trip) { _httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Bearer", StorageService.RetrieveToken()); var json = JsonConvert.SerializeObject(trip); var result = await _httpClient.PostAsync(new Uri($"{Globals.BASE_URL}/Trip"), new HttpStringContent(json, UnicodeEncoding.Utf8, "application/json")); return(JsonConvert.DeserializeObject <Trip>(await result.Content.ReadAsStringAsync())); }
public async Task <List <Trip> > GetTrips() { _httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Bearer", StorageService.RetrieveToken()); var json = await _httpClient.GetStringAsync(new Uri($"{Globals.BASE_URL}/Trip/GetTrips")); return(JsonConvert.DeserializeObject <List <Trip> >(json)); }