コード例 #1
0
 private void ExecuteUpdateItemCommand(ViewModels.TodoItemViewModel item)
 {
     try
     {
         TodoItemRepository.GetForToDoListId(TodoList.Id).UpdateItem(item.TodoItem.Id, item.TodoItem);
     }
     catch { }
 }
コード例 #2
0
 private void ExecuteRemoveCommand(Models.TodoItem param)
 {
     try
     {
         var index = this.Items.IndexOf(this.SelectedItem);
         // Delete from repo
         TodoItemRepository.GetForToDoListId(TodoList.Id).DeleteItem(this.SelectedItem.TodoItem.Id);
         this.Items.Remove(this.SelectedItem);
         this.SelectedItem = this.Items[index];
     }
     catch { this.SelectedItem = null; }
 }
コード例 #3
0
        public TodoListViewModel(Models.TodoList list)
        {
            this.TodoList = list;

            var repo      = TodoItemRepository.GetForToDoListId(list.Id);
            var todoItems = repo.GetAllItems();

            foreach (var item in todoItems)
            {
                this.Items.Add(new ViewModels.TodoItemViewModel(item));
            }
        }
コード例 #4
0
        private void ExecuteAddCommand(string title)
        {
            try
            {
                var index = this.Items.IndexOf(this.SelectedItem);
                var item  = new TodoItemViewModel(TodoItemRepository.GetDefault().Factory(title: title));
                // Set the ListId
                item.TodoItem.ListId = TodoList.Id;

                // Add to repo
                TodoItemRepository.GetForToDoListId(TodoList.Id).InsertItem(item.TodoItem);

                // Insert into ViewModel collection
                this.Items.Insert((index > -1) ? index : 0, item);
                this.SelectedItem = item;
            }
            catch { this.SelectedItem = null; }
        }