Ejemplo n.º 1
0
        public async Task InsertTodoItemAsync (ToDoItem todoItem)
        {
            try {                
				await todoTable.InsertAsync (todoItem); // Insert a new TodoItem into the local database. 
				await SyncAsync(); // send changes to the mobile service

                Items.Add (todoItem); 

            } catch (MobileServiceInvalidOperationException e) {
                Console.Error.WriteLine (@"ERROR {0}", e.Message);
            }
        }
Ejemplo n.º 2
0
		public ToDoItemWrapper (ToDoItem item)
		{
			ToDoItem = item;
		}
Ejemplo n.º 3
0
        public async void AddItem (View view)
        {
            if (client == null || string.IsNullOrWhiteSpace (textNewToDo.Text)) {
                return;
            }

            // Create a new item
            var item = new ToDoItem {
                Text = textNewToDo.Text,
                Complete = false
            };

            try {
                await toDoTable.InsertAsync(item); // insert the new item into the local database
                await SyncAsync(); // send changes to the mobile service

                if (!item.Complete) {
                    adapter.Add (item);
                }
            } catch (Exception e) {
                CreateAndShowDialog (e, "Error");
            }

            textNewToDo.Text = "";
        }
Ejemplo n.º 4
0
        public async Task CheckItem (ToDoItem item)
        {
            if (client == null) {
                return;
            }

            // Set the item as completed and update it in the table
            item.Complete = true;
            try {
                await toDoTable.UpdateAsync(item); // update the new item in the local database
                await SyncAsync(); // send changes to the mobile service

                if (item.Complete)
                    adapter.Remove (item);

            } catch (Exception e) {
                CreateAndShowDialog (e, "Error");
            }
        }
		async partial void OnAdd (UIButton sender)
		{
			if (string.IsNullOrWhiteSpace (itemText.Text))
				return;

			var newItem = new ToDoItem {
				Text = itemText.Text, 
				Complete = false
			};

			await todoService.InsertTodoItemAsync (newItem);

			var index = todoService.Items.FindIndex (item => item.Id == newItem.Id);

			TableView.InsertRows (new [] { NSIndexPath.FromItemSection (index, 0) },
			UITableViewRowAnimation.Top);

			itemText.Text = "";
		}
Ejemplo n.º 6
0
        public async Task CompleteItemAsync (ToDoItem item)
        {
            try {
				item.Complete = true; 
                await todoTable.UpdateAsync (item); // update todo item in the local database
				await SyncAsync(); // send changes to the mobile service

                Items.Remove (item);

            } catch (MobileServiceInvalidOperationException e) {
                Console.Error.WriteLine (@"ERROR {0}", e.Message);
            }
        }