예제 #1
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);
     }
 }
예제 #2
0
        public void Load()
        {
            var subtaskLogic = new SubtaskLogic();
            var subtasks     = subtaskLogic.GetByAssignmentId(assignment_id).Where(s => s.Status == EnumDefinition.SubtaskStatus.NotYetDone);

            this.SubtaskViewModels = subtasks
                                     .Select(s => new SubtaskComboBoxViewModel(s))
                                     .ToList();
            this.cb_Subtask.ItemsSource = this.SubtaskViewModels;
            this.cb_Subtask.IsEnabled   = this.SubtaskViewModels.Count > 0;
        }
        private void LoadSubtasksForAssignment(int assignment_id)
        {
            var subtaskLogic = new SubtaskLogic();

            this.SubtaskViewModels = subtaskLogic.GetByAssignmentId(assignment_id)
                                     .Select(s => new SubtaskComboBoxViewModel(s))
                                     .ToList();
            subtaskLogic.Dispose();
            this.SubtaskViewModels.Add(new SubtaskComboBoxViewModel {
                Id = 0, Name = ResourceStringManager.GetResourceByKey("All")
            });
            this.cb_SubtaskFilter.SelectedItem = this.SubtaskViewModels.Single(s => s.Id == 0);
        }
예제 #4
0
        public void GetByAssignmentId_Test()
        {
            // ARRANGE
            CreateSubtask();
            var subtaskLogic = new SubtaskLogic();

            // ACT
            var subtask = subtaskLogic.GetByAssignmentId(1);

            subtaskLogic.Dispose();

            // ASSERT
            Assert.IsNotNull(subtask);
        }