public override void GetPagedTasks(int pageNumber) { for (int i = (AllGoals.Count - 1); i >= 0; i--) { GoalViewModel goalVm = AllGoals[i]; this.AllGoals.Remove(goalVm); goalVm.Dispose(); } List <GoalViewModel> all = (from goal in _goalData.GetGoals(FilterTerm, SelectedSortColumn, pageNumber) select new GoalViewModel(goal, _goalData, _projectData, _taskData)).ToList(); foreach (GoalViewModel gvm in all) { gvm.PropertyChanged += this.OnGoalViewModelPropertyChanged; } for (int i = 0; i < all.Count; i++) { this.AllGoals.Add(all[i]); } FirstRecordNumber = AllGoals.Count > 0 ? (Constants.RecordsPerPage * (pageNumber - 1)) + 1 : 0; LastRecordNumber = AllGoals.Count > 0 ? FirstRecordNumber + AllGoals.Count - 1 : 0; TotalRecordCount = _goalData.GetGoalsCount(FilterTerm); }
/// <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(); } }