示例#1
0
        /// <summary>
        /// DELETE /tables/TodoItem/{id}
        /// </summary>
        public static void DeleteTodo(Task t)
        {
            WebClient client = new WebClient();
            try {
                // make it synchronous
                client.Headers.Add (HttpRequestHeader.Accept, "application/json");
                client.Headers.Add (HttpRequestHeader.ContentType, "application/json");
                client.Headers.Add ("X-ZUMO-APPLICATION", MobileServiceAppId);

                var payload = t.ToJson ();
                var response = client.UploadString (String.Format (DeleteUrl,t.Id), "DELETE", payload); // DELETE
                // ...and wait...
                var responseString = response;

                //var responseJson = JsonValue.Parse (responseString); //HACK:
                Console.WriteLine ("Delete Json response => " + responseString);

            } catch (System.Net.WebException e) {
                Console.WriteLine ("X-ZUMO-APPLICATION add failed" + e.Message);
            }
        }
示例#2
0
        /// <summary>
        /// DELETE /tables/TodoItem/{id}
        /// </summary>
        public static void DeleteTodo(Task t)
        {
            WebClient client = new WebClient();

            try {
                // make it synchronous
                client.Headers.Add(HttpRequestHeader.Accept, "application/json");
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                client.Headers.Add("X-ZUMO-APPLICATION", MobileServiceAppId);

                var payload  = t.ToJson();
                var response = client.UploadString(String.Format(DeleteUrl, t.Id), "DELETE", payload);                  // DELETE
                // ...and wait...
                var responseString = response;

                //var responseJson = JsonValue.Parse (responseString); //HACK:
                Console.WriteLine("Delete Json response => " + responseString);
            } catch (System.Net.WebException e) {
                Console.WriteLine("X-ZUMO-APPLICATION add failed" + e.Message);
            }
        }
示例#3
0
        /// <summary>
        /// POST /tables/TodoItem
        /// {"text":"new task text","complete":false}
        /// </summary>
        public static Task AddTodo(Task t)
        {
            WebClient client = new WebClient();
            try {
                // make it synchronous
                client.Headers.Add (HttpRequestHeader.Accept, "application/json");
                client.Headers.Add (HttpRequestHeader.ContentType, "application/json");
                client.Headers.Add ("X-ZUMO-APPLICATION", MobileServiceAppId);

                var payload = t.ToJson ();
                var response = client.UploadString (AddUrl, "POST", payload); // PATCH
                // ...and wait...
                var responseString = response;
                // RETURNS [{"id":1,"text":"Port to iOS and Android","complete":false}]
                Console.WriteLine ("Add Json response => " + responseString);

                var responseJson = JsonValue.Parse (responseString);
                return new Task(responseJson);

            } catch (System.Net.WebException e) {
                Console.WriteLine ("X-ZUMO-APPLICATION add failed" + e.Message);
            }
            return null;
        }
示例#4
0
        /// <summary>
        /// POST /tables/TodoItem
        ///
        /// </summary>
        public static void AddTodo(Task t)
        {
            WebClient client = new WebClient();

            try {
                // HACK: Android issue - see Validator method declaration
                ServicePointManager.ServerCertificateValidationCallback = Workaround.Validator;

                // make it synchronous
                client.Headers.Add(HttpRequestHeader.Accept, "application/json");
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                client.Headers.Add("X-ZUMO-APPLICATION", MobileServiceAppId);

                var payload  = t.ToJson();
                var response = client.UploadString(AddUrl, "POST", payload);                  // PATCH
                // ...and wait...
                var responseString = response;

                //var responseJson = JsonValue.Parse (responseString); //HACK:
                Console.WriteLine("Add Json response => " + responseString);
            } catch (System.Net.WebException e) {
                Console.WriteLine("X-ZUMO-APPLICATION add failed" + e.Message);
            }
        }
示例#5
0
        /// <summary>
        /// POST /tables/TodoItem
        /// 
        /// </summary>
        public static void AddTodo(Task t)
        {
            WebClient client = new WebClient();
            try {
                // HACK: Android issue - see Validator method declaration
                ServicePointManager.ServerCertificateValidationCallback = Workaround.Validator;

                // make it synchronous
                client.Headers.Add (HttpRequestHeader.Accept, "application/json");
                client.Headers.Add (HttpRequestHeader.ContentType, "application/json");
                client.Headers.Add ("X-ZUMO-APPLICATION", MobileServiceAppId);

                var payload = t.ToJson ();
                var response = client.UploadString (AddUrl, "POST", payload); // PATCH
                // ...and wait...
                var responseString = response;

                //var responseJson = JsonValue.Parse (responseString); //HACK:
                Console.WriteLine ("Add Json response => " + responseString);

            } catch (System.Net.WebException e) {
                Console.WriteLine ("X-ZUMO-APPLICATION add failed" + e.Message);
            }
        }
示例#6
0
        /// <summary>
        /// POST /tables/TodoItem
        /// {"text":"new task text","complete":false}
        /// </summary>
        public static Task AddTodo(Task t)
        {
            WebClient client = new WebClient();

            try {
                // make it synchronous
                client.Headers.Add(HttpRequestHeader.Accept, "application/json");
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                client.Headers.Add("X-ZUMO-APPLICATION", MobileServiceAppId);

                var payload  = t.ToJson();
                var response = client.UploadString(AddUrl, "POST", payload);                  // PATCH
                // ...and wait...
                var responseString = response;
                // RETURNS [{"id":1,"text":"Port to iOS and Android","complete":false}]
                Console.WriteLine("Add Json response => " + responseString);

                var responseJson = JsonValue.Parse(responseString);
                return(new Task(responseJson));
            } catch (System.Net.WebException e) {
                Console.WriteLine("X-ZUMO-APPLICATION add failed" + e.Message);
            }
            return(null);
        }