public async Task <string> BuildForm(string token, string formJSON, string path)
        {
            HttpResponseMessage response = null;
            string content = null;

            if (string.Empty.Equals(path))
            {
                // Create
                response = await _httpUtil.PostAsync(token, APIs.FORM_URL, formJSON);
            }
            else
            {
                // Edit
                response = await _httpUtil.PutAsync(token, APIs.ModifiedForm(path), formJSON);
            }

            if (response == null || !response.IsSuccessStatusCode)
            {
                return("{}");
            }

            content = await response.Content.ReadAsStringAsync();

            return(content);
        }
Пример #2
0
        public async Task <string> UpdateUserInfo(User user, string path)
        {
            JObject info = new JObject {
                { Keywords.EMAIL, user.Email },
                { Keywords.NAME, user.Name },
                { Keywords.ID_GROUP, user.IdGroup },
                { Keywords.PERMISSION, Keywords.USER.ToLower() },
                { Keywords.GENDER, user.Gender },
                { Keywords.PHONE, user.PhoneNumber },
                { Keywords.ADDRESS, user.Address },
                { Keywords.STATUS, 1 },
                { Keywords.SUBMIT, true }
            };

            JObject data = new JObject {
                { Keywords.DATA, info }
            };

            string apiURI = APIs.GetListSubmissionsURL(path) + "/" + user.Id;

            HttpResponseMessage response = await _httpUtil.PutAsync(user.Token, apiURI, JsonConvert.SerializeObject(data));

            if (response == null || !response.IsSuccessStatusCode)
            {
                return("{}");
            }

            string content = await response.Content.ReadAsStringAsync();

            return(content);
        }