public static async Task <ObservableCollection <Rental> > GetCartAsync() { using (HttpResponseMessage response = await ShoppingCartController.GetCart()) { int status = (int)response.StatusCode; string body = await response.Content.ReadAsStringAsync(); if (status == 200) { ObservableCollection <Rental> jsonBody = JsonConvert.DeserializeObject <ObservableCollection <Rental> >(body); return(jsonBody); } else if (status == 400) { throw new ArgumentException(body); } else if (status == 401) { throw new UnauthenticatedException(); } else if (status == 404) { return(new ObservableCollection <Rental>()); } else if (status == 500) { throw new ServerException(); } else { throw new Exception("An error occurred"); } } }