コード例 #1
0
        public async Task <PolicyModel> GetPoliciesDetail(string PolicyId)
        {
            PolicyModel list    = new PolicyModel();
            string      SiteUrl = ConfigurationManager.AppSettings["apiurl"];
            string      apiUrl  = SiteUrl + "api/Policy/GetPolicy?policyId=" + PolicyId;

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(apiUrl);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.GetAsync(apiUrl);

                if (response.IsSuccessStatusCode)
                {
                    var data = await response.Content.ReadAsStringAsync();

                    list = Newtonsoft.Json.JsonConvert.DeserializeObject <PolicyModel>(data);
                }
            }
            return(list);
        }
コード例 #2
0
        public async Task <bool> UpdatePolicy(string ocNum, string insuredName, string policyId, string userId)
        {
            PolicyModel list    = new PolicyModel();
            string      SiteUrl = ConfigurationManager.AppSettings["apiurl"];
            string      apiUrl  = SiteUrl + "api/Policy/UpdatePolicy?ocNum=" + ocNum + "&insuredName=" + insuredName + "&policyId=" + policyId + "&userId=" + userId;

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(apiUrl);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.GetAsync(apiUrl);

                if (response.IsSuccessStatusCode)
                {
                    var data = await response.Content.ReadAsStringAsync();

                    return(Newtonsoft.Json.JsonConvert.DeserializeObject <bool>(data));
                }
            }
            return(false);
        }