// Randomizes return id from list of all restaurants public static Restaurant GetRandom() { var apiCallTask = RestaurantApiHelper.GetAll(); var result = apiCallTask.Result; JArray jsonResponse = JsonConvert.DeserializeObject <JArray>(result); List <Restaurant> restaurantList = JsonConvert.DeserializeObject <List <Restaurant> >(jsonResponse.ToString()); return(restaurantList.ElementAt(new Random().Next(0, restaurantList.Count() - 1))); }
public static Restaurant GetDetails(int id) { var apiCallTask = RestaurantApiHelper.Get(id); var result = apiCallTask.Result; JObject jsonResponse = JsonConvert.DeserializeObject <JObject>(result); Restaurant restaurant = JsonConvert.DeserializeObject <Restaurant>(jsonResponse.ToString()); return(restaurant); }
public static List <Restaurant> GetRestaurants() { var apiCallTask = RestaurantApiHelper.GetAll(); var result = apiCallTask.Result; JArray jsonResponse = JsonConvert.DeserializeObject <JArray>(result); List <Restaurant> restaurantList = JsonConvert.DeserializeObject <List <Restaurant> >(jsonResponse.ToString()); return(restaurantList); }
public static void Delete(int id) { var apiCallTask = RestaurantApiHelper.Delete(id); }
public static void Put(Restaurant restaurant) { string jsonRestaurant = JsonConvert.SerializeObject(restaurant); var apiCallTask = RestaurantApiHelper.Put(restaurant.RestaurantId, jsonRestaurant); }