/// <summary>
        /// Deletes the selected goal.
        /// </summary>
        public void DeleteGoal()
        {
            GoalViewModel selectedGoalVM = AllGoals.FirstOrDefault(g => g.IsSelected == true);

            if (selectedGoalVM != null && WPFMessageBox.Show(Properties.Resources.Delete_Confirm, Properties.Resources.Goals_Delete_Confirm, WPFMessageBoxButtons.YesNo, WPFMessageBoxImage.Question) == WPFMessageBoxResult.Yes)
            {
                _goalData.DeleteGoal(_goalData.GetGoalByGoalId(selectedGoalVM.GoalId), _projectData, _taskData);
                selectedGoalVM.Dispose();
            }
        }
        /// <summary>
        /// Launches the edit goal window.
        /// </summary>
        public void EditGoal()
        {
            GoalView window = new GoalView();

            GoalViewModel selectedGoalVM = AllGoals.FirstOrDefault(g => g.IsSelected == true);

            using (var viewModel = new GoalViewModel(_goalData.GetGoalByGoalId(selectedGoalVM.GoalId), _goalData, _projectData, _taskData))
            {
                this.ShowWorkspaceAsDialog(window, viewModel);
            }
        }
        public AllGoalsViewModel(GoalData goalData, ProjectData projectData, TaskData taskData)
        {
            if (goalData == null)
            {
                throw new ArgumentNullException("goalData");
            }

            if (projectData == null)
            {
                throw new ArgumentNullException("projectData");
            }

            if (taskData == null)
            {
                throw new ArgumentNullException("taskData");
            }

            base.DisplayName  = Properties.Resources.Goals_DisplayName;
            base.DisplayImage = "pack://application:,,,/TaskConqueror;Component/Assets/Images/goal.png";

            _goalData    = goalData;
            _projectData = projectData;
            _taskData    = taskData;

            // Subscribe for notifications of when a new goal is saved.
            _goalData.GoalAdded   += this.OnGoalAdded;
            _goalData.GoalUpdated += this.OnGoalUpdated;
            _goalData.GoalDeleted += this.OnGoalDeleted;

            // Populate the AllGoals collection with GoalViewModels.
            this.AllGoals = new ObservableCollection <GoalViewModel>();
            this.AllGoals.CollectionChanged += this.OnCollectionChanged;

            this.PageFirst();

            SortColumns.Add(new SortableProperty()
            {
                Description = "Title", Name = "Title"
            });
            SortColumns.Add(new SortableProperty()
            {
                Description = "Status", Name = "StatusId"
            });
            SortColumns.Add(new SortableProperty()
            {
                Description = "Category", Name = "CategoryId"
            });
            SortColumns.Add(new SortableProperty()
            {
                Description = "Date Created", Name = "CreatedDate"
            });
            SortColumns.Add(new SortableProperty()
            {
                Description = "Date Completed", Name = "CompletedDate"
            });

            SelectedSortColumn = SortColumns.FirstOrDefault();

            // select the first goal
            GoalViewModel firstGoal = AllGoals.FirstOrDefault();

            if (firstGoal != null)
            {
                firstGoal.IsSelected = true;
            }
        }