Ejemplo 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);
     }
 }
Ejemplo n.º 2
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();
        }
        /// <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;
        }
        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();
        }
        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);
        }
        /// <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();
        }
        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;
        }
        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();
        }
Ejemplo n.º 9
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);
            }
        }