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); } }
public async Task <User> GetByIdAsync(long id) { SDKClient client = new SDKClient(appKey, appSecret, serverRoot); Dictionary <string, object> data = new Dictionary <string, object>(); data["id"] = id; var result = await client.GetAsync("User/GetById", data); if (result.StatusCode == System.Net.HttpStatusCode.OK) { //因为返回的报文体是新增id:{5} //使用newtonsoft把json格式反序列化为long return(JsonConvert.DeserializeObject <User>(result.Result)); } else { throw new ApplicationException("GetById失败,状态码" + result.StatusCode + ",响应报文" + result.Result); } }
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 long id = JsonConvert.DeserializeObject <long>(result.Result); return(id); } else { throw new ApplicationException("新增失败,状态码" + result.StatusCode + ",响应报文" + result.Result); } }