public void Add() { var itemWindow = new ToDoItemWindow(_projectId); if (this is TodayToDoItemOperations) { itemWindow.ShowDialog(DateTime.Today); } else { itemWindow.ShowDialog(); } if (itemWindow.DialogResult == false) { return; } itemWindow.Item.ProjectId = _projectId; ItemService.Add(itemWindow.Item); if (itemWindow.Item.Id != -1 && IsCorrect(itemWindow.Item)) { _toDoItemsCollection.Add(itemWindow.Item); } else if (itemWindow.Item.Id == -1) { return; } _tagService.ReplaceItemsTags(itemWindow.Item.Id, itemWindow.SelectedTagsId); }
public void Selected() { var index = _toDoItemsListView.SelectedIndex; if (index == -1) { return; } var item = _toDoItemsCollection[index]; var itemWindow = new ToDoItemWindow(_projectId, item); _toDoItemsListView.SelectedItem = null; itemWindow.ShowDialog(); if (itemWindow.ToDelete) { if (ItemService.Remove(item)) { _toDoItemsCollection.Remove(item); } return; } // User closed a window. if (itemWindow.DialogResult == false) { return; } itemWindow.Item.ProjectName = item.ProjectName; ItemService.Update(itemWindow.Item); if (IsCorrect(itemWindow.Item)) { _toDoItemsCollection[index] = itemWindow.Item; } else { _toDoItemsCollection.Remove(item); } _tagService.ReplaceItemsTags(item.Id, itemWindow.SelectedTagsId); }