Ejemplo n.º 1
0
        // Remove a to-do task item from the database and collections.
        public void DeleteToDoItem(ToDoItem toDoForDelete)
        {
            // Remove the to-do item from the "all" observable collection.
            AllToDoItems.Remove(toDoForDelete);

            // Remove the to-do item from the data context.
            toDoDB.Items.DeleteOnSubmit(toDoForDelete);

            // Remove the to-do item from the appropriate category.
            switch (toDoForDelete.Category.Name)
            {
            case "Home":
                HomeToDoItems.Remove(toDoForDelete);
                break;

            case "Work":
                WorkToDoItems.Remove(toDoForDelete);
                break;

            case "Hobbies":
                HobbiesToDoItems.Remove(toDoForDelete);
                break;

            default:
                break;
            }

            // Save changes to the database.
            toDoDB.SubmitChanges();
        }
Ejemplo n.º 2
0
        // Remove a to-do task item from the database and collections.
        public void DeleteToDoItem(ToDoItem toDoForDelete)
        {
            // Remove the to-do item from the "all" observable collection.
            AllToDoItems.Remove(toDoForDelete);

            // Remove the to-do item from the data context.
            toDoDB.Items.DeleteOnSubmit(toDoForDelete);

            // Remove the to-do item from the appropriate category.

            if (toDoForDelete.Category.Id == 1)
            {
                HomeToDoItems.Remove(toDoForDelete);
            }
            else if (toDoForDelete.Category.Id == 2)
            {
                WorkToDoItems.Remove(toDoForDelete);
            }
            else
            {
                HobbiesToDoItems.Remove(toDoForDelete);
            }



            // Save changes to the database.
            toDoDB.SubmitChanges();
        }
Ejemplo n.º 3
0
        public void DeleteToDoItem(ToDoItem deleteToDoItem)
        {
            AllToDoItems.Remove(deleteToDoItem);

            switch (deleteToDoItem.Category.Name)
            {
            case "Home":
                HomeToDoItems.Remove(deleteToDoItem);
                break;

            case "Work":
                WorkToDoItems.Remove(deleteToDoItem);
                break;

            case "Hobbies":
                HomeToDoItems.Remove(deleteToDoItem);
                break;

            default:
                break;
            }

            toDoDb.Items.DeleteOnSubmit(deleteToDoItem);
            toDoDb.SubmitChanges();
        }