public GoalViewModel(Goal goal, GoalData goalData, ProjectData projectData, TaskData taskData)
        {
            if (goal == null)
            {
                throw new ArgumentNullException("goal");
            }

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

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

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

            _goal                = goal;
            _goalData            = goalData;
            _projectData         = projectData;
            _taskData            = taskData;
            _statusOptions       = AppInfo.Instance.StatusList;
            _selectedStatus      = _statusOptions.FirstOrDefault(s => s.StatusID == this.StatusId);
            _categoryOptions     = AppInfo.Instance.CategoryList;
            _selectedCategory    = _categoryOptions.FirstOrDefault(c => c.CategoryID == this.CategoryId);
            _isSaved             = true;
            _statusDescription   = _statusOptions.FirstOrDefault(s => s.StatusID == this.StatusId).Description;
            _categoryDescription = _categoryOptions.FirstOrDefault(c => c.CategoryID == this.CategoryId).Description;
            List <Project> childProjects = _goalData.GetChildProjects(_goal.GoalId);

            foreach (Project childProject in childProjects)
            {
                _childProjectVMs.Add(new ProjectViewModel(childProject, projectData, taskData));
            }

            _originalStatusId = StatusId;

            // Subscribe for notifications of when a new project is saved.
            _projectData.ProjectAdded   += this.OnProjectAdded;
            _projectData.ProjectUpdated += this.OnProjectUpdated;
            _projectData.ProjectDeleted += this.OnProjectDeleted;

            base.DisplayName  = Properties.Resources.Edit_Goal_DisplayName;
            base.DisplayImage = "pack://application:,,,/TaskConqueror;Component/Assets/Images/goal.png";
        }
        public MainWindowViewModel()
        {
            base.DisplayName = Properties.Resources.AppName;
            _taskData        = new TaskData();
            _projectData     = new ProjectData();
            _goalData        = new GoalData();
            WorkspaceViewModel activeVM = ListActiveTasks();

            ListTasks();
            ListProjects();
            ListGoals();
            ListReports();
            ShowAdminOptions();
            this.SetActiveWorkspace(activeVM);
        }
Example #3
0
        public override FlowDocument Build()
        {
            FlowDocument flowDocument = base.Build();

            Dictionary <string, Tuple <string, string> > columnDefinitions = new Dictionary <string, Tuple <string, string> >()
            {
                { "Title", new Tuple <string, string>("Title", null) },
                { "StatusDescription", new Tuple <string, string>("Status", null) },
                { "CategoryDescription", new Tuple <string, string>("Category", null) },
                { "CreatedDate", new Tuple <string, string>("Date Created", null) },
                { "CompletedDate", new Tuple <string, string>("Date Completed", null) }
            };

            using (GoalData gData = new GoalData())
            {
                using (ProjectData pData = new ProjectData())
                {
                    using (TaskData tData = new TaskData())
                    {
                        List <Goal>          completedGoals = gData.GetCompletedGoalsByDate(StartDate, EndDate);
                        List <GoalViewModel> rowData        = new List <GoalViewModel>();
                        foreach (Goal goal in completedGoals)
                        {
                            rowData.Add(new GoalViewModel(goal, gData, pData, tData));
                        }

                        flowDocument.Blocks.Add(FlowDocumentHelper.BuildTable <GoalViewModel>(columnDefinitions, rowData));

                        foreach (GoalViewModel goalVm in rowData)
                        {
                            goalVm.Dispose();
                        }
                    }
                }
            }

            return(flowDocument);
        }
Example #4
0
        /// <summary>
        /// Update the specified project into the db.
        /// If the project is not already in the repository, an
        /// exception is thrown.
        /// </summary>
        public void UpdateProject(Project project, TaskData taskData)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (project.ProjectId == 0)
            {
                throw new InvalidOperationException("modify project");
            }

            Data.Project dbProject = (from p in _appInfo.GcContext.Projects
                                      where p.ProjectID == project.ProjectId
                                      select p).FirstOrDefault();

            if (dbProject == null)
            {
                throw new InvalidDataException("project id");
            }
            else
            {
                dbProject.StatusID      = project.StatusId;
                dbProject.EstimatedCost = project.EstimatedCost;
                dbProject.CreatedDate   = project.CreatedDate;
                dbProject.CompletedDate = project.CompletedDate;
                dbProject.Title         = project.Title;

                _appInfo.GcContext.SaveChanges();

                if (this.ProjectUpdated != null)
                {
                    this.ProjectUpdated(this, new ProjectUpdatedEventArgs(project, dbProject));
                }

                taskData.UpdateTasksByProject(project.ProjectId);
            }
        }
Example #5
0
        public UnassignedTreeNodeViewModel(TaskData taskData, ProjectData projectData, ITreeNodeContainerViewModel parent)
        {
            if (taskData == null)
            {
                throw new ArgumentNullException("task data");
            }

            List <Project> unassignedProjects = projectData.GetUnassignedProjectsContainingInactiveTasks();

            foreach (Project unassignedProject in unassignedProjects)
            {
                _childNodes.Add(new ProjectTreeNodeViewModel(unassignedProject, projectData, this));
            }

            List <Task> unassignedTasks = taskData.GetUnassignedInactiveTasks();

            foreach (Task unassignedTask in unassignedTasks)
            {
                _childNodes.Add(new TaskTreeNodeViewModel(unassignedTask, this));
            }

            _parent = parent;
        }
        public ProjectViewModel(Project project, ProjectData projectData, TaskData taskData)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

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

            _project           = project;
            _projectData       = projectData;
            _taskData          = taskData;
            _statusOptions     = AppInfo.Instance.StatusList;
            _selectedStatus    = _statusOptions.FirstOrDefault(s => s.StatusID == this.StatusId);
            _isSaved           = true;
            _goalTitle         = _project.ParentGoal == null ? null : _project.ParentGoal.Title;
            _statusDescription = _statusOptions.FirstOrDefault(s => s.StatusID == this.StatusId).Description;
            List <Task> childTasks = _projectData.GetChildTasks(_project.ProjectId);

            foreach (Task childTask in childTasks)
            {
                _childTaskVMs.Add(new TaskViewModel(childTask, taskData));
            }

            _originalStatusId = StatusId;

            // Subscribe for notifications of when a new task is saved.
            _taskData.TaskAdded   += this.OnTaskAdded;
            _taskData.TaskUpdated += this.OnTaskUpdated;
            _taskData.TaskDeleted += this.OnTaskDeleted;

            base.DisplayName  = Properties.Resources.Edit_Project_DisplayName;
            base.DisplayImage = "pack://application:,,,/TaskConqueror;Component/Assets/Images/project.png";
        }
        public override FlowDocument Build()
        {
            FlowDocument flowDocument = base.Build();

            Dictionary <string, Tuple <string, string> > columnDefinitions = new Dictionary <string, Tuple <string, string> >()
            {
                { "Title", new Tuple <string, string>("Title", null) },
                { "StatusDescription", new Tuple <string, string>("Status", null) },
                { "GoalTitle", new Tuple <string, string>("Goal", null) },
                { "EstimatedCost", new Tuple <string, string>("Est. Cost", "{0:C}") },
                { "CreatedDate", new Tuple <string, string>("Date Created", null) },
                { "CompletedDate", new Tuple <string, string>("Date Completed", null) }
            };

            using (ProjectData pData = new ProjectData())
            {
                using (TaskData tData = new TaskData())
                {
                    List <Project>          completedProjects = pData.GetCompletedProjectsByDate(StartDate, EndDate);
                    List <ProjectViewModel> rowData           = new List <ProjectViewModel>();
                    foreach (Project project in completedProjects)
                    {
                        rowData.Add(new ProjectViewModel(project, pData, tData));
                    }

                    flowDocument.Blocks.Add(FlowDocumentHelper.BuildTable <ProjectViewModel>(columnDefinitions, rowData));

                    foreach (ProjectViewModel projectVm in rowData)
                    {
                        projectVm.Dispose();
                    }
                }
            }

            return(flowDocument);
        }
Example #8
0
        public AddTasksViewModel(TaskData taskData, ProjectData projectData, GoalData goalData)
        {
            if (taskData == null)
            {
                throw new ArgumentNullException("taskData");
            }

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

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

            List <Goal> allGoals = goalData.GetGoalsContainingInactiveTasks();

            foreach (Goal goalObj in allGoals)
            {
                _root.ChildNodes.Add(new GoalTreeNodeViewModel(goalObj, goalData, _root));
            }

            UnassignedTreeNodeViewModel unassigned = new UnassignedTreeNodeViewModel(taskData, projectData, _root);

            if (unassigned.ChildNodes.Count > 0)
            {
                _root.ChildNodes.Add(unassigned);
            }

            _taskData = taskData;

            base.DisplayName  = Properties.Resources.Add_Tasks_DisplayName;
            base.DisplayImage = "pack://application:,,,/TaskConqueror;Component/Assets/Images/task.png";
        }
        public override FlowDocument Build()
        {
            FlowDocument flowDocument = new FlowDocument();

            flowDocument.Blocks.Add(FlowDocumentHelper.BuildTitle(Title));

            Paragraph criteriaPara = new Paragraph();
            Span      titleSpan    = new Span();

            titleSpan.Inlines.Add("Title: ");
            titleSpan.FontWeight = FontWeights.Bold;
            Span titleValueSpan = new Span();

            titleValueSpan.Inlines.Add(SelectedGoal.Title);
            Span dateTitleSpan = new Span();

            dateTitleSpan.Inlines.Add("     Date Created: ");
            dateTitleSpan.FontWeight = FontWeights.Bold;
            Span dateValueSpan = new Span();

            dateValueSpan.Inlines.Add(SelectedGoal.CreatedDate.ToShortDateString());
            criteriaPara.Inlines.Add(titleSpan);
            criteriaPara.Inlines.Add(titleValueSpan);
            criteriaPara.Inlines.Add(dateTitleSpan);
            criteriaPara.Inlines.Add(dateValueSpan);
            flowDocument.Blocks.Add(criteriaPara);

            Dictionary <string, Tuple <string, string> > columnDefinitions = new Dictionary <string, Tuple <string, string> >()
            {
                { "Title", new Tuple <string, string>("Project Title", null) },
                { "StatusDescription", new Tuple <string, string>("Status", null) },
                { "EstimatedCost", new Tuple <string, string>("Estimated Cost", "0:C") },
                { "CreatedDate", new Tuple <string, string>("Date Created", null) },
                { "CompletedDate", new Tuple <string, string>("Date Completed", null) }
            };

            using (ProjectData pData = new ProjectData())
            {
                using (TaskData tData = new TaskData())
                {
                    using (GoalData gData = new GoalData())
                    {
                        List <Project>          childProjects = gData.GetChildProjects(SelectedGoal.GoalId);
                        List <ProjectViewModel> rowData       = new List <ProjectViewModel>();
                        foreach (Project project in childProjects)
                        {
                            rowData.Add(new ProjectViewModel(project, pData, tData));
                        }

                        flowDocument.Blocks.Add(FlowDocumentHelper.BuildTable <ProjectViewModel>(columnDefinitions, rowData));

                        foreach (ProjectViewModel projectVm in rowData)
                        {
                            projectVm.Dispose();
                        }
                    }
                }
            }

            return(flowDocument);
        }
        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;
            }
        }
Example #11
0
        public AddChildProjectsViewModel(ProjectData projectData, Goal parentGoal, GoalData goalData, TaskData taskData)
        {
            if (projectData == null)
            {
                throw new ArgumentNullException("projectData");
            }

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

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

            List <Project> unassignedProjects = projectData.GetUnassignedProjects();

            foreach (Project unassignedProject in unassignedProjects)
            {
                _unassignedProjects.Add(new ProjectViewModel(unassignedProject, projectData, taskData));
            }

            _parentGoal  = parentGoal;
            _goalData    = goalData;
            _projectData = projectData;

            base.DisplayName  = Properties.Resources.Add_Projects_DisplayName;
            base.DisplayImage = "pack://application:,,,/TaskConqueror;Component/Assets/Images/project.png";
        }