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(); }
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(); }
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>>(); } }
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(); }
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>>(); } }
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("没有找到"); } }
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; } }
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(); }
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(); }