/// <summary>
        /// Replaces the item identified by the whereClause
        /// </summary>
        /// <param name="items">The items to modify</param>
        /// <param name="whereClause">The predicate to use</param>
        /// <param name="item">The new item</param>
        /// <returns>True if an item was updated</returns>
        public static bool ReplaceIf(this ObservableCollection <TodoItem> items, Func <TodoItem, bool> whereClause, TodoItem item)
        {
            var index = items.IndexOf(whereClause);

            if (index >= 0)
            {
                items[index] = item;
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
 public TodoListEventArgs(TodoListAction action, TodoItem item)
 {
     Action = action;
     Item   = item;
 }
Esempio n. 3
0
 private void OnTodoListChanged(TodoListAction action, TodoItem item)
 => TodoListUpdated?.Invoke(this, new TodoListEventArgs(action, item));
Esempio n. 4
0
 /// <summary>
 /// Saves an item to the table, calling either update or add, depending on if it exists.
 /// </summary>
 /// <param name="item">The item to be saved</param>
 public Task SaveTodoItemAsync(TodoItem item)
 => (item.Id == null) ? AddTodoItemAsync(item) : UpdateTodoItemAsync(item);