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);
        }
        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);
        }
Esempio n. 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);
     }
 }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            DynamicStartingConfig config = new DynamicStartingConfig();

            RVS1 = new Warehouse(config.FCName,
                                 config.BrandInUse,
                                 config.FirstIsle,
                                 config.LastIsle,
                                 config.OddIsles,
                                 config.EvenIsles
                                 );

            AssignmentLogic LogicEngine = new AssignmentLogic();

            LogicEngine.GetSkus();
            LogicEngine.AssignIsles(RVS1);
            LogicEngine.WriteSkus(RVS1);

            int maxIsle         = RVS1.Isles.Max(i => i.IsleID);
            int maxBayInMaxIsle = RVS1.Isles.FirstOrDefault(i => i.IsleID == maxIsle).Bays.Max(b => b.BayID);
            int maxShelf        = 5;
            int maxPosition     = 8;

            Console.WriteLine("The last shelf position is: " + RVS1.Isles.FirstOrDefault(i => i.IsleID == maxIsle)
                              .Bays.FirstOrDefault(b => b.BayID == maxBayInMaxIsle)
                              .Shelves.FirstOrDefault(s => s.ShelfID == maxShelf)
                              .Positions.FirstOrDefault(p => p.PositionID == maxPosition).Location());

            Console.WriteLine(Directory.GetCurrentDirectory());
        }
Esempio n. 5
0
        public AssignmentController(ApplicationDbContext context, UserManager <ApplicationUser> userManager, IHostingEnvironment env)
        {
            _context     = context;
            _userManager = userManager;
            _env         = env;

            _assignmentLogic = new AssignmentLogic(context, userManager, env);
        }
Esempio n. 6
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();
        }
Esempio n. 7
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);
     }
 }
        /// <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;
        }
        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();
        }
        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();
        }
        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);
        }
        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);
        }
        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));
        }
        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();
        }
        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);
        }
Esempio n. 17
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);
         }
     }
 }
Esempio n. 18
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();
         }
     }
 }
Esempio n. 19
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;
            }
        }
        public OpenAssignmentsViewModel(int project_Id)
        {
            if (project_Id != 0)
            {
                AssignmentLogic assignmentLogic = new AssignmentLogic();

                var assignments = assignmentLogic.GetAssignmentsByProjectId(project_Id)
                                  .Where(a => a.AssignmentStatus == Common.Enums.EnumDefinition.AssignmentStatus.InProgress ||
                                         a.AssignmentStatus == Common.Enums.EnumDefinition.AssignmentStatus.Future ||
                                         a.AssignmentStatus == Common.Enums.EnumDefinition.AssignmentStatus.Postponed)
                                  .ToList();
                if (assignments.Any())
                {
                    AssignmentNames = new List <string>();

                    foreach (var assignment in assignments)
                    {
                        AssignmentNames.Add(assignment.Name);
                    }
                }
            }
        }
        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;
        }
        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);
        }
        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();
        }
Esempio n. 24
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);
            }
        }