コード例 #1
0
        public async Task AddUserToGroupAsync(long userGroupId, long userId)
        {
            SDKClient client = new SDKClient(appKey, appSecret, serverRoot);
            Dictionary <string, object> data = new Dictionary <string, object>();

            data["userGroupId"] = userGroupId;
            data["userId"]      = userId;
            var result = await client.GetAsync("UserGroup/AddUserToGroup", data);

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
            }
            else
            {
                throw new ApplicationException("AddUserToGroup失败,状态码"
                                               + result.StatusCode + ",响应报文" + result.Result);
            }
        }
コード例 #2
0
ファイル: UserApi.cs プロジェクト: 1715174428/biji
        public async Task <bool> UserExistsAsync(string phoneNum)
        {
            SDKClient client = new SDKClient(appKey, appSecret, serverRoot);
            Dictionary <string, object> data = new Dictionary <string, object>();

            data["phoneNum"] = phoneNum;
            var result = await client.GetAsync("User/UserExists", data);

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(JsonConvert.DeserializeObject <bool>(result.Result));
            }
            else
            {
                throw new ApplicationException("UserExists失败,状态码"
                                               + result.StatusCode + ",响应报文" + result.Result);
            }
        }
コード例 #3
0
        public async Task <User> GetByPhoneNumAsync(string phoneNum)
        {
            SDKClient client = new SDKClient(appKey, appSecret, serverRoot);
            Dictionary <string, object> data = new Dictionary <string, object>();

            data["phoneNum"] = phoneNum;
            var result = await client.GetAsync("User/GetByPhoneNum", data);

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //因为返回的报文体是新增id:{5}
                //使用newtonsoft把json格式反序列化为long
                return(JsonConvert.DeserializeObject <User>(result.Result));
            }
            else
            {
                throw new ApplicationException("GetByPhoneNum 失败,状态码" + result.StatusCode + ",响应报文" + result.Result);
            }
        }
コード例 #4
0
        public async Task <long> addNewAsync(string phoneNum, string nickName, string password)
        {
            SDKClient client = new SDKClient(appKey, appSecret, serverRoot);
            Dictionary <string, object> data = new Dictionary <string, object>();

            data["phoneNum"] = phoneNum;
            data["nickName"] = nickName;
            data["password"] = password;
            var result = await client.GetAsync("User/AddNew", data);

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                long id = JsonConvert.DeserializeObject <long>(result.Result);
                return(id);
            }
            else
            {
                throw new ApplicationException($"新增失败,状态码{nameof(result.StatusCode)},响应报文{nameof(result.Result)}");
            }
        }
コード例 #5
0
        public async Task RemoveUserFromGroupAsync(long userGroupId, long userId)
        {
            SDKClient client = new SDKClient(appKey, appSecret, serverRoot);
            Dictionary <string, object> data = new Dictionary <string, object>();

            data["userGroupId"] = userGroupId;
            data["userId"]      = userId;
            var result = await client.GetAsync("UserGroup/RemoveUserFromGroup", data);

            if (result.StatusCode == System.Net.HttpStatusCode.NoContent)
            {
                //因为返回的报文体是新增id:{5}
                //使用newtonsoft把json格式反序列化为long
            }
            else
            {
                throw new ApplicationException("RemoveUserFromGroup 失败,状态码"
                                               + result.StatusCode + ",响应报文" + result.Result);
            }
        }
コード例 #6
0
        public async Task <long> AddNewAsync(string phoneNum, string nickName, string password)
        {
            SDKClient client = new SDKClient(appKey, appSecret, serverRoot);
            Dictionary <string, object> data = new Dictionary <string, object>();

            data["phoneNum"] = phoneNum;
            data["nickName"] = nickName;
            data["password"] = password;
            var result = await client.GetAsync("User/AddNew", data);

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //因为返回的报文体是新增id:{5}
                //使用newtonsoft把json格式反序列化为long
                return(JsonConvert.DeserializeObject <long>(result.Result));
            }
            else
            {
                throw new ApplicationException("AddNew失败,状态码" + result.StatusCode + ",响应报文" + result.Result);
            }
        }