コード例 #1
0
        public void UpdateAssignment_Test()
        {
            // ARRANGE
            var assignment  = CreateTestAssignment();
            var updateParam = new AssignmentUpdateParam
            {
                Name                   = "TestAssignment Updated",
                DateDue                = DateTime.Now.AddDays(1),
                DatePlanned            = DateTime.Now,
                Description            = "New description Updated",
                DurationPlannedAsTicks = new TimeSpan(1, 0, 0).Ticks,
            };
            var assignmentLogic = new AssignmentLogic();

            // ACT
            assignmentLogic.UpdateAssignment(assignment.Id, updateParam);
            assignmentLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var updatedAssignment = uow.Assignments.Get(assignment.Id);

            Assert.AreNotEqual(assignment.Name, updatedAssignment.Name);
            Assert.AreEqual("TestAssignment Updated", updatedAssignment.Name);
        }
コード例 #2
0
        public void AddAssignment_Test()
        {
            // ARRANGE
            CreateTestProjectAndProjectType();
            var project = uow.Projects.GetAll().First();

            var createParam = new AssignmentCreateParam
            {
                Name                   = "TestAssignment",
                DateDue                = DateTime.Now.AddDays(1),
                DatePlanned            = DateTime.Now,
                Description            = "New description",
                DurationPlannedAsTicks = new TimeSpan(1, 0, 0).Ticks,
                Project                = project
            };

            var assignmentLogic = new AssignmentLogic();

            // ACT
            assignmentLogic.AddAssignment(createParam);
            assignmentLogic.Dispose();

            // ASSERT
            var assignments = uow.Assignments.GetAll().ToList();

            Assert.IsTrue(assignments.Count > 0);
            Assert.AreEqual("TestAssignment", assignments.First(a => a.Name == "TestAssignment").Name);
        }
コード例 #3
0
 private void CheckForSubtasksForAssignmentAndCreateIfNecessary(int assignment_id)
 {
     try
     {
         var subtaskLogic     = new SubtaskLogic();
         var existingSubtasks = subtaskLogic.GetByAssignmentId(assignment_id);
         if (existingSubtasks == null || existingSubtasks.Count() == 0)
         {
             var assignmentLogic = new AssignmentLogic();
             var assignment      = assignmentLogic.GetAssignmentById(assignment_id);
             var defaultSubtask  = new SubtaskCreateViewModel
             {
                 Name        = assignment.Name,
                 Description = assignment.Description,
                 Priority    = EnumDefinition.SubtaskPriority.Medium
             };
             assignmentLogic.AddSubtask(assignment_id, defaultSubtask);
             assignmentLogic.Dispose();
         }
         subtaskLogic.Dispose();
     }
     catch (Exception e)
     {
         Logger.LogException(e);
         MessageBox.Show(e.Message);
     }
 }
コード例 #4
0
        private void Load(int assignment_id)
        {
            var assignmentLogic = new AssignmentLogic();

            this.Assignment         = assignmentLogic.GetAssignmentById(assignment_id);
            this.GridViewModels     = Assignment.Subtasks.Select(s => new SubtaskGridViewModel(s)).ToList();
            this.PagingManager.Data = this.GridViewModels;
            assignmentLogic.Dispose();
        }
コード例 #5
0
 private void btn_DeleteSubtask_Click(object sender, RoutedEventArgs e)
 {
     if (this.SelectedSubtask != null)
     {
         var assignmentLogic = new AssignmentLogic();
         assignmentLogic.DeleteSubtask(this.Assignment.Id, this.SelectedSubtask.Id);
         assignmentLogic.Dispose();
         Load(this.Assignment.Id);
         RefreshBindings(this.PagingManager.CurrentPage);
     }
 }
コード例 #6
0
        /// <summary>
        /// For new subtasks for existing assignments
        /// </summary>
        /// <param name="assigment"></param>
        public AddSubtask(int assigment_id)
        {
            InitializeComponent();
            this.EditMode = false;
            var assignmentLogic = new AssignmentLogic();

            this.Assignment = assignmentLogic.GetAssignmentById(assigment_id);
            assignmentLogic.Dispose();
            this.cb_PrioritySelect.SelectedItem = this.cbi_Medium;
            this.SelectedPriority = EnumDefinition.SubtaskPriority.Medium;
        }
コード例 #7
0
        private static void ChangeParentAssignmentToInProgress(Subtask subtask)
        {
            // Update AssignmentStatus to InProgress
            if (subtask == null)
            {
                return;
            }
            var assignmentLogic = new AssignmentLogic();

            assignmentLogic.UpdateAssignmentStatus(subtask.Assignment_Id.GetValueOrDefault(0), EnumDefinition.AssignmentStatus.InProgress);
            assignmentLogic.Dispose();
        }
コード例 #8
0
        private void LoadAssignmentsForProject(int project_id)
        {
            var assignmentLogic = new AssignmentLogic();

            this.AssignmentViewModels = assignmentLogic.GetAssignmentsByProjectId(project_id)
                                        .Select(a => new AssignmentViewModel(a))
                                        .ToList();
            assignmentLogic.Dispose();
            this.AssignmentViewModels.Add(new AssignmentViewModel {
                Id = 0, Name = ResourceStringManager.GetResourceByKey("All")
            });
            this.cb_AssignmentFilter.SelectedItem = this.AssignmentViewModels.Single(a => a.Id == 0);
        }
コード例 #9
0
        public AddAssignment(int assignment_id, int project_id)
        {
            InitializeComponent();
            var assignmentLogic = new AssignmentLogic();
            var projectLogic    = new ProjectLogic();

            this.Assignment = assignmentLogic.GetAssignmentById(assignment_id);
            this.Project    = projectLogic.GetProjectById(project_id);
            assignmentLogic.Dispose();
            projectLogic.Dispose();
            this.EditMode = true;
            Load();
        }
コード例 #10
0
        public void SetAborted_Test()
        {
            // ARRANGE
            var assignment      = CreateTestAssignment();
            var assignmentLogic = new AssignmentLogic();

            // ACT
            assignmentLogic.SetAborted(assignment.Id);
            assignmentLogic.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var updatedAssignment = uow.Assignments.Get(assignment.Id);

            Assert.AreEqual(EnumDefinition.AssignmentStatus.Aborted, updatedAssignment.AssignmentStatus);
        }
コード例 #11
0
        public void GetAssignmentsByProjectId_Test()
        {
            // ARRANGE
            var assignment      = CreateTestAssignment();
            int projectId       = assignment.Project_Id.Value;
            var assignmentLogic = new AssignmentLogic();

            // ACT
            var foundAssignments = assignmentLogic.GetAssignmentsByProjectId(projectId);

            assignmentLogic.Dispose();

            // ASSERT
            Assert.IsNotNull(foundAssignments);
            Assert.IsTrue(foundAssignments.All(a => a.Project_Id.Value == projectId));
        }
コード例 #12
0
        public void GetAssignmentById_Test()
        {
            // ARRANGE
            var createdAssignment = CreateTestAssignment();
            int assignmentId      = createdAssignment.Id;
            var assignmentLogic   = new AssignmentLogic();

            // ACT
            var foundAssignment = assignmentLogic.GetAssignmentById(assignmentId);

            assignmentLogic.Dispose();

            // ASSERT
            Assert.IsNotNull(foundAssignment);
            Assert.AreEqual(createdAssignment.Name, foundAssignment.Name);
        }
コード例 #13
0
        public void DeleteAssignment_Test()
        {
            // ARRANGE
            var assignment      = CreateTestAssignment();
            var assignmentLogic = new AssignmentLogic();

            // ACT
            assignmentLogic.DeleteAssignment(assignment.Id);
            assignmentLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var foundAssignment = uow.Assignments.Get(assignment.Id);

            Assert.IsNull(foundAssignment);
        }
コード例 #14
0
        /// <summary>
        /// For existing subtasks for existing assignments
        /// </summary>
        /// <param name="subtaskId"></param>
        public AddSubtask(int subtask_id, int assignment_id)
        {
            InitializeComponent();
            var subtaskLogic    = new SubtaskLogic();
            var assignmentLogic = new AssignmentLogic();
            var subtask         = subtaskLogic.GetById(subtask_id);

            this.EditMode        = true;
            this.EditableSubtask = subtask;
            this.cb_PrioritySelect.SelectedItem = GetItemByPriority(subtask.Priority);
            this.tb_SubtaskDescription.Text     = subtask.Description;
            this.tb_SubtaskName.Text            = subtask.Name;
            this.Assignment = assignmentLogic.GetAssignmentById(assignment_id);

            assignmentLogic.Dispose();
            subtaskLogic.Dispose();
        }
コード例 #15
0
 private void btn_DeleteAssignment_Click(object sender, RoutedEventArgs e)
 {
     if (this.SelectedAssignment != null)
     {
         try
         {
             var assignmentLogic = new AssignmentLogic();
             assignmentLogic.DeleteAssignment(this.SelectedAssignment.Id);
             assignmentLogic.Dispose();
             this.Load();
             this.RefreshBindings(this.PagingManager.CurrentPage);
         }
         catch (Exception ex)
         {
             Logger.LogException(ex);
         }
     }
 }
コード例 #16
0
 private void btn_SetAborted_Click(object sender, RoutedEventArgs e)
 {
     Logger.Log(string.Format("{0}.btn_SetAborted_Click", GetType().FullName));
     if (this.SelectedAssignment != null)
     {
         try
         {
             var assignmentLogic = new AssignmentLogic();
             assignmentLogic.SetAborted(this.SelectedAssignment.Id);
             assignmentLogic.Dispose();
             this.Load();
             this.RefreshBindings(this.PagingManager.CurrentPage);
         }
         catch (CannotChangeStatusException ex)
         {
             Logger.LogException(ex);
             ShowErrorOnStatusChangeDialog();
         }
     }
 }
コード例 #17
0
        private void Load()
        {
            var assignmentLogic = new AssignmentLogic();

            this.AssignmentViewModels = assignmentLogic.GetAllAssignments()
                                        .Select(a => new AssignmentViewModel(a))
                                        .OrderBy(avm => avm.DueDate)
                                        .ThenBy(avm => avm.Planned);
            this.FilteredAssignmentViewModels = PipeThroughFilter(this.AssignmentViewModels);
            assignmentLogic.Dispose();
            this.PagingManager.Data         = this.FilteredAssignmentViewModels.ToList();
            this.LoadFromAllProjects        = true;
            this.lv_Assignments.ItemsSource = this.PagingManager.Page(this.PagingManager.CurrentPage);
            if (this.cb_ProjectSelection.SelectedItem != null)
            {
                this.cb_ProjectSelection.SelectedItem = this.SelectedProject;
            }
            if (this.cb_StatusFilter.SelectedItem != null)
            {
                this.cb_StatusFilter.SelectedItem = this.SelectedFilter;
            }
        }
コード例 #18
0
        private void Load()
        {
            if (!EditMode)
            {
                return;
            }
            var assignmentLogic = new AssignmentLogic();

            this.Assignment = assignmentLogic.GetAssignmentById(this.Assignment.Id);
            assignmentLogic.Dispose();

            this.tb_AssignmentDescription.Text          = this.Assignment.Description;
            this.tb_AssignmentName.Text                 = this.Assignment.Name;
            this.tb_AssignmentPlannedDurationHours.Text = Assignment.DurationPlannedAsTicks.HasValue
                ? new TimeSpan(this.Assignment.DurationPlannedAsTicks.Value).Hours.ToString()
                : null;
            this.tb_AssignmentPlannedDurationMinutes.Text = Assignment.DurationPlannedAsTicks.HasValue
                ? new TimeSpan(this.Assignment.DurationPlannedAsTicks.Value).Minutes.ToString()
                : null;
            this.dp_AssignmentDue.SelectedDate = this.Assignment.DateDue;
            this.dp_Planned.SelectedDate       = this.Assignment.DatePlanned;
        }
コード例 #19
0
        public void AddSubtask_Test()
        {
            // ARRANGE
            var assignment         = CreateTestAssignment();
            var assignmentLogic    = new AssignmentLogic();
            var subtaskCreateParam = new SubtaskCreateParam
            {
                Description = "Test description",
                Name        = "Test subtask",
                Priority    = EnumDefinition.SubtaskPriority.High
            };

            // ACT
            assignmentLogic.AddSubtask(assignment.Id, subtaskCreateParam);
            assignmentLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var subtask = this.uow.Subtasks.Load(s => s.Assignment_Id == assignment.Id).First();

            Assert.IsNotNull(subtask);
        }
コード例 #20
0
        private void btn_AddAssignment_Click(object sender, RoutedEventArgs e)
        {
            var        assignmentLogic = new AssignmentLogic();
            Assignment assignment      = null;
            var        durationPlanned = ParseDuration();

            if (this.EditMode)
            {
                var param = new AssignmentUpdateParam
                {
                    DateDue                = this.dp_AssignmentDue.SelectedDate,
                    DatePlanned            = this.dp_Planned.SelectedDate,
                    Description            = this.tb_AssignmentDescription.Text,
                    DurationPlannedAsTicks = durationPlanned,
                    Name = this.tb_AssignmentName.Text
                };
                assignmentLogic.UpdateAssignment(this.Assignment.Id, param);
                assignment = assignmentLogic.GetAssignmentById(this.Assignment.Id);
            }
            else
            {
                var param = new AssignmentCreateParam
                {
                    DateDue                = this.dp_AssignmentDue.SelectedDate,
                    DatePlanned            = this.dp_Planned.SelectedDate,
                    Description            = this.tb_AssignmentDescription.Text,
                    DurationPlannedAsTicks = durationPlanned,
                    Name    = this.tb_AssignmentName.Text,
                    Project = this.Project
                };

                assignment = assignmentLogic.AddAssignment(param);
            }

            assignmentLogic.Dispose();
            this.Close();
        }
コード例 #21
0
        private void ShowAddAssignmentDialog(bool editMode)
        {
            AddAssignment addAssignmentWindow = null;
            var           projectLogic        = new ProjectLogic();
            int?          projectId           = null;

            if (this.SelectedProject != null)
            {
                projectId = this.SelectedProject.Id;
            }
            else if (this.SelectedAssignment != null)
            {
                projectId = this.SelectedAssignment.ProjectId;
            }
            if (projectId.HasValue)
            {
                var project = projectLogic.GetProjectById(projectId.Value);
                projectLogic.Dispose();

                if (editMode)
                {
                    var assignmentLogic    = new AssignmentLogic();
                    var selectedAssignment = assignmentLogic.GetAssignmentById(this.SelectedAssignment.Id);
                    assignmentLogic.Dispose();
                    addAssignmentWindow = new AddAssignment(selectedAssignment.Id, selectedAssignment.Project_Id.Value);
                }
                else
                {
                    addAssignmentWindow = new AddAssignment(project.Id);
                }

                addAssignmentWindow.ShowDialog();
                this.Load();
                this.RefreshBindings(this.PagingManager.CurrentPage);
            }
        }