Exemple #1
0
        protected async Task <long> AddNewAsync <TObj>(TObj dto) where TObj : class
        {
            SDKResult result = await client.PutAsync("Put", dto);

            JObject obj = JsonConvert.DeserializeObject <JObject>(result.Result);

            if (result.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                ErrorMsg = obj["errorMsg"].ToString();
                return(-1);
            }
            else if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(JsonConvert.DeserializeObject <long>(obj["data"].ToString()));
            }
            else
            {
                throw new ApplicationException("未知的错误");
            }
        }