Esempio n. 1
0
 public string Save(string target, IDictionary<string, string> query,
     IDictionary<string, object> attributes)
 {
     var url = new UrlBuilder(baseUrl).Concat(target).WithQueries(query, "@")
         .WithQuery("save", "true").ToUrl();
     var res = Invoke("POST", url, attributes, HttpStatusCode.OK);
     return res["value"].ToString();
 }
Esempio n. 2
0
 public string UpdateById(string target, string id, IDictionary<string, object> attributes)
 {
     var url = new UrlBuilder(baseUrl).Concat(target, id).ToUrl();
     var res = Invoke("PUT", url, attributes, HttpStatusCode.OK);
     return res["value"].ToString();
 }
Esempio n. 3
0
        public IList<IDictionary<string, Object>> Children(string parent, string parent_id,
            string target, IDictionary<string, string> query)
        {
            var url = new UrlBuilder(baseUrl).Concat(parent, parent_id, "children", target).
                WithQueries(query, "@").ToUrl();

            var res = Invoke("GET", url, null, HttpStatusCode.OK);
            object obj;
            if (res.TryGetValue("value", out obj))
            {
                return ToObjects(obj as IEnumerable<object>);
            }
            else
            {
                return new List<IDictionary<string, Object>>();
            }
        }
Esempio n. 4
0
 public string Create(string target, IDictionary<string, object> attributes)
 {
     var url = new UrlBuilder(baseUrl).Concat(target).ToUrl();
     var res = Invoke("POST", url, attributes, HttpStatusCode.Created);
     return res["value"].ToString();
 }
Esempio n. 5
0
        public IList<IDictionary<string, Object>> FindByWithIncludes(string target, 
            IDictionary<string, string> query, string includes)
        {
            var url = new UrlBuilder(baseUrl).Concat(target, "query").
                WithQueries(query, "@").
                WithQuery("includes", includes).ToUrl();

            var res = Invoke("GET", url, null, HttpStatusCode.OK);
            object obj;
            if (res.TryGetValue("value", out obj))
            {
                return ToObjects(obj as IEnumerable<object>);
            }
            else
            {
                return new List<IDictionary<string, Object>>();
            }
        }
Esempio n. 6
0
 public IDictionary<string, object> FindByIdWithIncludes(string target, string id, string includes)
 {
     var url = new UrlBuilder(baseUrl).Concat(target, id).WithQuery("includes", includes).ToUrl();
     var res = Invoke("GET", url, null, HttpStatusCode.OK);
     object obj;
     if (res.TryGetValue("value", out obj))
     {
         return ToDictionary((JObject)obj);
     }
     else
     {
         throw new ApplicationException("没有找到");
     }
 }
Esempio n. 7
0
        public int Count(string target, IDictionary<string, string> query)
        {
            var url = new UrlBuilder(baseUrl).Concat(target, "count").WithQueries(query, "@").ToUrl();
            var res = Invoke("GET", url, null, HttpStatusCode.OK);

            object obj;
            if (res.TryGetValue("value", out obj))
            {
                return int.Parse(res["value"].ToString());
            }
            else
            {
                return 0;
            }
        }
Esempio n. 8
0
 public string DeleteBy(string target, IDictionary<string, string> query)
 {
     var url = new UrlBuilder(baseUrl).Concat(target, "query").WithQueries(query, "@").ToUrl();
     var res = Invoke("DELETE", url, null, HttpStatusCode.OK);
     return res["value"].ToString();
 }
Esempio n. 9
0
 public string DeleteById(string target, string id)
 {
     var url = new UrlBuilder(baseUrl).Concat(target, id).ToUrl();
     var res = Invoke("DELETE", url, null, HttpStatusCode.OK);
     return res["value"].ToString();
 }