void OnAddItemClicked (object sender, EventArgs e)
		{
			var todoItem = new TodoItem () {
				ID = Guid.NewGuid ().ToString ()
			};
			var todoPage = new TodoItemPage (true);
			todoPage.BindingContext = todoItem;
			Navigation.PushAsync (todoPage);
		}
Esempio n. 2
0
		public async Task SaveTodoItemAsync (TodoItem item, bool isNewItem = false)
		{
			// RestUrl = http://developer.xamarin.com:8081/api/todoitems{0}
			var uri = new Uri (string.Format (Constants.RestUrl, item.ID));

			try {
				var json = JsonConvert.SerializeObject (item);
				var content = new StringContent (json, Encoding.UTF8, "application/json");

				HttpResponseMessage response = null;
				if (isNewItem) {
					response = await client.PostAsync (uri, content);
				} else {
					response = await client.PutAsync (uri, content);
				}
				
				if (response.IsSuccessStatusCode) {
					Debug.WriteLine (@"				TodoItem successfully saved.");
				}
				
			} catch (Exception ex) {
				Debug.WriteLine (@"				ERROR {0}", ex.Message);
			}
		}
		public Task DeleteTaskAsync (TodoItem item)
		{
			return restService.DeleteTodoItemAsync (item.ID);
		}
		public Task SaveTaskAsync (TodoItem item, bool isNewItem = false)
		{
			return restService.SaveTodoItemAsync (item, isNewItem);
		}
Esempio n. 5
0
 public Task DeleteTaskAsync(TodoItem item)
 {
     return(restService.DeleteTodoItemAsync(item.ID));
 }
Esempio n. 6
0
 public Task SaveTaskAsync(TodoItem item, bool isNewItem = false)
 {
     return(restService.SaveTodoItemAsync(item, isNewItem));
 }
Esempio n. 7
0
 public Task SaveTaskAsync(TodoItem item)
 {
     return(restService.SaveTodoItemAsync(item));
 }