// Randomizes return id from list of all shops public static Shop GetRandom() { var apiCallTask = ShopApiHelper.GetAll(); var result = apiCallTask.Result; JArray jsonResponse = JsonConvert.DeserializeObject <JArray>(result); List <Shop> restaurantList = JsonConvert.DeserializeObject <List <Shop> >(jsonResponse.ToString()); return(restaurantList.ElementAt(new Random().Next(0, restaurantList.Count() - 1))); }
public static Shop GetDetails(int id) { var apiCallTask = ShopApiHelper.Get(id); var result = apiCallTask.Result; JObject jsonResponse = JsonConvert.DeserializeObject <JObject>(result); Shop shop = JsonConvert.DeserializeObject <Shop>(jsonResponse.ToString()); return(shop); }
public static List <Shop> GetShops() { var apiCallTask = ShopApiHelper.GetAll(); var result = apiCallTask.Result; JArray jsonResponse = JsonConvert.DeserializeObject <JArray>(result); List <Shop> shopList = JsonConvert.DeserializeObject <List <Shop> >(jsonResponse.ToString()); return(shopList); }
public static void Delete(int id) { var apiCallTask = ShopApiHelper.Delete(id); }
public static void Put(Shop shop) { string jsonShop = JsonConvert.SerializeObject(shop); var apiCallTask = ShopApiHelper.Put(shop.ShopId, jsonShop); }