示例#1
0
        public static List <Item> GetItems()
        {
            var apiCallTask = ItemApiHelper.GetAll();
            var result      = apiCallTask.Result;

            JArray      jsonResponse = JsonConvert.DeserializeObject <JArray>(result);
            List <Item> itemList     = JsonConvert.DeserializeObject <List <Item> >(jsonResponse.ToString());

            return(itemList);
        }
示例#2
0
        public static Item GetDetails(int id)
        {
            var apiCallTask = ItemApiHelper.Get(id);
            var result      = apiCallTask.Result;

            JObject jsonResponse = JsonConvert.DeserializeObject <JObject>(result);
            // foreach(PropertyDescriptor descriptor in TypeDescriptor.GetProperties(jsonResponse))
            // {

            //     string name=descriptor.Name;
            //     object value=descriptor.GetValue(jsonResponse);
            //     System.Console.WriteLine("{0}={1}",name,value);
            // }

            Item item = JsonConvert.DeserializeObject <Item>(jsonResponse.ToString());

            return(item);
        }
示例#3
0
 public static void AddCategory(int itemId, int categoryId)
 {
     var apiCallTask = ItemApiHelper.AddCategory(itemId, categoryId);
 }
示例#4
0
 public static void Delete(int id)
 {
     var apiCallTask = ItemApiHelper.Delete(id);
 }
示例#5
0
 public static void Put(Item item, int categoryId)
 {
     string jsonItem    = JsonConvert.SerializeObject(item);
     var    apiCallTask = ItemApiHelper.Put(item.ItemId, jsonItem, categoryId);
 }