Example #1
0
        /// <summary>
        /// DELETE /tables/TodoItem/{id}
        /// </summary>
        public static void DeleteTodo(TodoItem 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);
            }
        }
Example #2
0
        /// <summary>
        /// DELETE /tables/TodoItem/{id}
        /// </summary>
        public static void DeleteTodo(TodoItem 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);
            }
        }
Example #3
0
        /// <summary>
        /// POST /tables/TodoItem
        /// {"text":"new task text","complete":false}
        /// </summary>
        public static TodoItem AddTodo(TodoItem 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 TodoItem(responseJson);

            } catch (System.Net.WebException e) {
                Console.WriteLine ("X-ZUMO-APPLICATION add failed" + e.Message);
            }
            return null;
        }
Example #4
0
        /// <summary>
        /// POST /tables/TodoItem
        /// {"text":"new task text","complete":false}
        /// </summary>
        public static TodoItem AddTodo(TodoItem 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 TodoItem(responseJson));
            } catch (System.Net.WebException e) {
                Console.WriteLine("X-ZUMO-APPLICATION add failed" + e.Message);
            }
            return(null);
        }