Esempio n. 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);
     }
 }
Esempio n. 2
0
        public void Update_Test()
        {
            // ARRANGE
            CreateSubtask();
            var subtaskUpdateParam = new SubtaskUpdateParam
            {
                Description = "Subtask description updated",
                Name        = "Subtask name updated",
                Priority    = EnumDefinition.SubtaskPriority.Highest
            };
            var subtaskLogic = new SubtaskLogic();

            // ACT
            subtaskLogic.Update(1, subtaskUpdateParam);
            subtaskLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var updated = this.uow.Subtasks.Get(1);

            Assert.IsNotNull(updated);
            Assert.AreEqual(subtaskUpdateParam.Name, updated.Name);
            Assert.AreEqual(subtaskUpdateParam.Description, updated.Description);
            Assert.AreEqual(subtaskUpdateParam.Priority, updated.Priority);
        }
Esempio n. 3
0
        public void AddEntry_Test()
        {
            // ARRANGE
            CreateSubtask();
            var subtask          = this.uow.Subtasks.Get(1);
            var project          = this.uow.Projects.Get(1);
            var entryCreateParam = new EntryCreateParam
            {
                Name    = "Test entry",
                Comment = "Test comment",
                Date    = DateTime.Now.Date,
                Started = DateTime.Now.AddHours(-2),
                Ended   = DateTime.Now.AddHours(-1)
            };
            var subtaskLogic = new SubtaskLogic();

            // ACT
            subtaskLogic.AddEntry(subtask.Id, entryCreateParam);
            subtaskLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var inserted = this.uow.Entries.Get(1);

            Assert.IsNotNull(inserted);
            Assert.AreEqual(subtask.Id, inserted.Subtask_Id.Value);
        }
        public void CreateEntry()
        {
            var projectLogic = new ProjectLogic();
            var project      = projectLogic.GetProjectById(project_id);

            projectLogic.Dispose();
            var subtaskLogic = new SubtaskLogic();
            var subtask      = subtaskLogic.GetById(this.SelectedSubtask.Id);

            ChangeParentAssignmentToInProgress(subtask);

            var entryCreateViewModel = new EntryCreateViewModel
            {
                Comment         = this.tb_Description.Text,
                Date            = DateTime.Now,
                Name            = this.tb_Name.Text,
                Project         = project,
                Subtask         = subtask,
                DurationAsTicks = this.DurationElapsed.Ticks,
                Ended           = this.stopped,
                Started         = this.started
            };

            subtaskLogic.AddEntry(this.SelectedSubtask.Id, entryCreateViewModel, this.chebo_FinishesSubtask.IsChecked.Value);
            subtaskLogic.Dispose();

            this.Close();
        }
Esempio n. 5
0
 private void btn_TickSubtask_Click(object sender, RoutedEventArgs e)
 {
     if (this.SelectedSubtask != null)
     {
         var subtaskLogic = new SubtaskLogic();
         subtaskLogic.SetSubtaskTickedOff(this.SelectedSubtask.Id);
         subtaskLogic.Dispose();
         this.Load(this.Assignment.Id);
         RefreshBindings(this.PagingManager.CurrentPage);
     }
 }
        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 cb_Subtask_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
     {
         this.SelectedSubtask = e.AddedItems[0] as SubtaskComboBoxViewModel;
         this.tb_Name.Text    = this.SelectedSubtask.Name;
         var subtaskLogic = new SubtaskLogic();
         var subtask      = subtaskLogic.GetById(this.SelectedSubtask.Id);
         this.timekeeperMax = new TimeSpan(subtask.Assignment.GetDifferenceOfPlannedAndElapsedTicks().GetValueOrDefault());
         subtaskLogic.Dispose();
     }
 }
        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);
        }
Esempio n. 9
0
        public void GetById_Test()
        {
            // ARRANGE
            CreateSubtask();
            var subtaskLogic = new SubtaskLogic();

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

            subtaskLogic.Dispose();

            // ASSERT
            Assert.IsNotNull(subtask);
        }
Esempio n. 10
0
        public void Delete_Test()
        {
            // ARRANGE
            CreateSubtask();
            var subtaskLogic = new SubtaskLogic();

            // ACT
            subtaskLogic.Delete(1);
            subtaskLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var deleted = this.uow.Subtasks.Get(1);

            Assert.IsNull(deleted);
        }
        /// <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();
        }