Пример #1
0
        /// <summary>
        /// Delete the specified goal and descendents from the db.
        /// If the goal is not already in the repository, an
        /// exception is thrown.
        /// </summary>
        public void DeleteGoal(Goal goal, ProjectData projectData, TaskData taskData)
        {
            if (goal == null)
            {
                throw new ArgumentNullException("goal");
            }

            if (goal.GoalId == 0)
            {
                throw new InvalidOperationException("delete goal");
            }

            var query = (from g in _appInfo.GcContext.Goals
                         where g.GoalID == goal.GoalId
                         select g).First();

            Goal requestedGoal = Goal.CreateGoal(query);

            // delete child projects first
            List <Project> childProjects = this.GetChildProjects(requestedGoal.GoalId);

            foreach (Project childProject in childProjects)
            {
                projectData.DeleteProject(childProject, taskData);
            }

            _appInfo.GcContext.DeleteObject(query);
            _appInfo.GcContext.SaveChanges();

            if (this.GoalDeleted != null)
            {
                this.GoalDeleted(this, new GoalDeletedEventArgs(goal));
            }
        }
Пример #2
0
        /// <summary>
        /// Deletes the selected project.
        /// </summary>
        public void DeleteProject()
        {
            ProjectViewModel selectedProjectVM = AllProjects.FirstOrDefault(p => p.IsSelected == true);

            if (selectedProjectVM != null && WPFMessageBox.Show(Properties.Resources.Delete_Confirm, Properties.Resources.Projects_Delete_Confirm, WPFMessageBoxButtons.YesNo, WPFMessageBoxImage.Question) == WPFMessageBoxResult.Yes)
            {
                _projectData.DeleteProject(_projectData.GetProjectByProjectId(selectedProjectVM.ProjectId), _taskData);
                selectedProjectVM.Dispose();
            }
        }