示例#1
0
        public virtual void Update(Dictionary <string, object> tokens, string subEndpoint = null, string filepath = null)
        {
            string endpoint = RecordEndpoint + "/" + this["id"].ToString();

            if (subEndpoint != null)
            {
                endpoint += subEndpoint;
            }

            if (filepath == null)
            {
                string body = JsonConvert.SerializeObject(tokens);

                var task = RecordClient.HttpPatchAsync(endpoint, body);
                task.Wait();

                UpdateRecord(task.Result);
            }
            else
            {
                Dictionary <string, string> postFields = new Dictionary <string, string> ();
                foreach (KeyValuePair <string, object> entry in tokens)
                {
                    postFields.Add(entry.Key, entry.Value.ToString());
                }

                var task = RecordClient.HttpPatchFormAsync(endpoint, filepath, postFields);
                task.Wait();

                UpdateRecord(task.Result);
            }
        }
示例#2
0
        public virtual void Read(string endpoint, Dictionary <string, string> query)
        {
            var task = RecordClient.HttpGetAsync(RecordEndpoint + endpoint, query);

            task.Wait();

            UpdateList(task.Result);
        }
示例#3
0
        public virtual void Create(Dictionary <string, object> tokens, string endponit)
        {
            string body = JsonConvert.SerializeObject(tokens);
            var    task = RecordClient.HttpPostAsync(RecordEndpoint + endponit, body);

            task.Wait();

            UpdateRecord(task.Result);
        }
示例#4
0
        public virtual void Delete()
        {
            string endpoint = RecordEndpoint + "/" + this["id"].ToString();

            var task = RecordClient.HttpDeleteAsync(endpoint);

            task.Wait();

            UpdateRecord(empty_record);
        }
示例#5
0
        public virtual void Read(long id)
        {
            string endpoint = RecordEndpoint + "/" + id.ToString();

            var task = RecordClient.HttpGetAsync(endpoint, new Dictionary <string, string>());

            task.Wait();

            UpdateRecord(task.Result);
        }
示例#6
0
        public virtual void Update()
        {
            string endpoint = RecordEndpoint + "/" + this["id"].ToString();
            string body     = JsonConvert.SerializeObject(cache);

            var task = RecordClient.HttpPatchAsync(endpoint, body);

            task.Wait();

            UpdateRecord(task.Result);
        }