예제 #1
0
        public static void Finish(int taskId)
        {
            if (taskId > 0)
            {
                ProjectsRepository     projectsRepository     = new ProjectsRepository(new DB.PmcsDbContext());
                ProjectTasksRepository projectTasksRepository = new ProjectTasksRepository(new DB.PmcsDbContext());

                var original = projectTasksRepository.GetById(t => t.TaskId == taskId);
                var newTask  = projectTasksRepository.GetById(t => t.TaskId == taskId);
                newTask.CompletionPercentage = 1.00;
                newTask.TaskStatus           = 2;
                newTask.TaskComplete         = true;
                newTask.ActualEndDate        = DateTime.Now;

                projectTasksRepository.Update(original, newTask);

                if (original.ParentTaskId != null)
                {
                    var childrenTasks = projectTasksRepository
                                        .SearchData(t => t.ParentTaskId == original.ParentTaskId)
                                        .ToList();

                    if (childrenTasks.Any() && childrenTasks.All(t => t.TaskComplete == true))
                    {
                        var originalParent = projectTasksRepository.GetById(t => t.TaskId == original.ParentTaskId);
                        var newParentTask  = projectTasksRepository.GetById(t => t.TaskId == original.ParentTaskId);
                        newParentTask.CompletionPercentage = 1.00;
                        newParentTask.TaskStatus           = 2;
                        newParentTask.TaskComplete         = true;
                        projectTasksRepository.Update(originalParent, newParentTask);
                    }
                }
            }
        }
예제 #2
0
 public IEnumerable <ProjectTask> GetTasksByParentTaskId(int parentTaskId)
 {
     return(projectTasksRepository
            .SearchData(p => p.ParentTaskId == parentTaskId)
            .Select(t => t.AutoMapObject <DB.Task, ProjectTask>()));
 }