示例#1
0
        public void RemoveTask(TreeTaskViewModel task)
        {
            var taskToRemove = _selectedTasks.SingleOrDefault(t => t.Task.Id == task.Task.Id);

            if (taskToRemove != null)
            {
                _selectedTasks.Remove(taskToRemove);
            }
        }
示例#2
0
        public void AddTask(TreeTaskViewModel task)
        {
            if (_selectedTasks.Count(t => t.Task.Id == task.Task.Id) == 0)
            {
                _selectedTasks.Add(task);
            }

            AddProject((TreeProjectViewModel)task.Parent);
        }
示例#3
0
        public void TaskSelected(TreeTaskViewModel task)
        {
            _selectionFilter.AddTask(task);
            var customerViewModel = Customers.SingleOrDefault(c => c.Customer.CustomerID == task.Task.Project.CustomerID);

            if (customerViewModel != null) // Customer already in list
            {
                var projectViewModel =
                    customerViewModel.Projects.Single(p => p.Project.Id == task.Task.ProjectID);

                if (!customerViewModel.VisibleChildren.Contains(projectViewModel))
                {
                    customerViewModel.AddVisibleChild(projectViewModel);
                }

                var taskVm = projectViewModel.Tasks.Single(x => x.Task.Id == task.Task.Id);
                taskVm.SetAllChildrenVisibleByFilters(_timeEntryFilter, _selectionFilter);
                projectViewModel.AddVisibleChild(taskVm);
            }
            else // Customer not in list. Add it
            {
                // Customer
                var customerVm = task.ParentProject.ParentCustomer.ListCustomerViewModel;

                // Project
                var projectVm = customerVm.Projects.Single(x => x.Project.Id == task.ParentProject.Project.Id);
                projectVm.SetAllChildrenNonVisible();
                customerVm.AddVisibleChild(projectVm);

                // Task
                var taskVm = projectVm.Tasks.Single(x => x.Task.Id == task.Task.Id);
                taskVm.SetAllChildrenVisibleByFilters(_timeEntryFilter, _selectionFilter);
                projectVm.AddVisibleChild(taskVm);

                Customers.Add(customerVm);
            }
            OnPropertyChanged("Customers");
        }
示例#4
0
        private void TaskDeSelected(TreeTaskViewModel task)
        {
            _selectionFilter.RemoveTask(task);

            var customerViewModel = Customers.ToList().SingleOrDefault(c => c.Customer.Id == task.Task.Project.CustomerID);

            if (customerViewModel != null)
            {
                var projectViewModel =
                    customerViewModel.Children.SingleOrDefault(p => ((ListProjectViewModel)p).Project.Id == task.Task.ProjectID);

                if (projectViewModel != null)
                {
                    var taskViewModel =
                        projectViewModel.Children.SingleOrDefault(t => ((ListTaskViewModel)t).Task.Id == task.Task.Id);

                    if (taskViewModel != null)
                    {
                        projectViewModel.VisibleChildren.Remove(taskViewModel);
                    }

                    if (projectViewModel.VisibleChildren.Count == 0)
                    {
                        customerViewModel.VisibleChildren.Remove(projectViewModel);
                        _selectionFilter.RemoveProject(task.ParentProject);
                    }

                    if (customerViewModel.VisibleChildren.Count == 0)
                    {
                        Customers.Remove(customerViewModel);
                        _selectionFilter.RemoveCustomer(task.ParentProject.ParentCustomer);
                    }
                }
            }
            //UpdateTotalTimeBillable();
        }