示例#1
0
        public bool TestCreateCustomer(string baseURI)
        {
            HttpResponseMessage jResponse = null;

            try
            {
                CallService oWebAPICall = new CallService();

                jResponse = oWebAPICall.Call(baseURI, "CreateCustomer/" + CustomerId + "/" + Title + "/" + FirstName + "/" + LastName);
                string     jsonResponse = jResponse.Content.ReadAsAsync <string>().Result;
                ResultBool rt           = JsonConvert.DeserializeObject <ResultBool>(jsonResponse);

                jResponse.Dispose();

                return(rt.Value);
            }
            catch (Exception e)
            {
                Console.Write("Test failed with exception: " + e.Message);
                return(false);
            }
            finally
            {
                jResponse.Dispose();
            }
        }
        public bool TestReadCustomer(string baseURI)
        {
            try
            {
                CallService oWebAPICall = new CallService();

                HttpResponseMessage jResponse = oWebAPICall.Call(baseURI, "ReadCustomer/1");
                string     jsonResponse       = jResponse.Content.ReadAsAsync <string>().Result;
                ResultBool rt = JsonConvert.DeserializeObject <ResultBool>(jsonResponse);

                jResponse.Dispose();

                return(rt.Value);
            }
            catch (Exception e)
            {
                Console.Write("Test failed with exception: " + e.Message);
                return(false);
            }
        }