public void InsertProject_Test()
        {
            // ARRANGE
            CreateProjectType();
            var projectType        = this.uow.ProjectTypes.GetAll().First();
            var projectCreateParam = new ProjectCreateParam
            {
                Description = "Test description",
                Name        = "Test project",
                ProjectType = projectType
            };
            var projectLogic = new ProjectLogic();

            // ACT
            projectLogic.InsertProject(projectCreateParam);
            projectLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var createdProject = this.uow.Projects.GetAll().First();

            Assert.IsNotNull(createdProject);
            Assert.AreEqual(EnumDefinition.ProjectStatus.Active, createdProject.ProjectStatus);
        }
        private void CreateProject()
        {
            CreateProjectType();
            var projectType = this.uow.ProjectTypes.GetAll().First();
            var createParam = new ProjectCreateParam
            {
                Name        = "Test project",
                Description = "Test description",
                ProjectType = projectType
            };

            this.uow.Projects.Add(Project.Create(createParam));
            this.uow.Complete();
        }
        public Task CreateAsync(ProjectCreateParam projectDto)
        {
            Projects.Project project = ObjectMapper.Map <ProjectCreateParam, Projects.Project>(projectDto);
            project.CreationTime = DateTime.Now;
            project.CreatorId    = CurrentUser.Id;
            project.TenantId     = CurrentTenant.Id;
            project.IsDeleted    = false;
            var existed = ProjectRepository.FirstOrDefault(c => c.Name == project.Name);

            if (existed != null)
            {
                throw new ArgumentException(L["ProjectError:NameDuplicate"]);
            }
            ProjectRepository.InsertAsync(project);
            return(Task.CompletedTask);
        }
        private void CreateTestProjectAndProjectType()
        {
            GetTestUnitOfWork();
            var projectTypeCreateParam = new ProjectTypeCreateParam
            {
                Name        = "Test",
                Description = "Test project type"
            };

            var projectCreateParam = new ProjectCreateParam
            {
                Description = "Project description",
                Name        = "New project",
                ProjectType = ProjectType.Create(projectTypeCreateParam)
            };

            uow.ProjectTypes.Add(ProjectType.Create(projectTypeCreateParam));
            uow.Projects.Add(Project.Create(projectCreateParam));
            uow.Complete();
        }
        private Assignment CreateTestAssignment()
        {
            var projectTypeCreateParam = new ProjectTypeCreateParam
            {
                Name        = "Test",
                Description = "Test project type"
            };

            var projectCreateParam = new ProjectCreateParam
            {
                Description = "Project description",
                Name        = "New project",
                ProjectType = ProjectType.Create(projectTypeCreateParam)
            };

            uow.ProjectTypes.Add(ProjectType.Create(projectTypeCreateParam));
            uow.Projects.Add(Project.Create(projectCreateParam));
            uow.Complete();

            var project = uow.Projects.GetAll().First(p => p.Name == "New project");
            var assignmentCreateParam = new AssignmentCreateParam
            {
                Name                   = "TestAssignment",
                DateDue                = DateTime.Now.AddDays(1),
                DatePlanned            = DateTime.Now,
                Description            = "New description",
                DurationPlannedAsTicks = new TimeSpan(1, 0, 0).Ticks,
                Project                = project
            };

            uow.Assignments.Add(Assignment.Create(assignmentCreateParam));
            uow.Complete();

            var assignment = uow.Assignments.Load(a => a.Name == "TestAssignment").Single();

            return(assignment);
        }
Beispiel #6
0
        private void CreatePrerequisitesForSubtaskCreation()
        {
            var projectTypeCreateParam = new ProjectTypeCreateParam
            {
                Name        = "Test",
                Description = "Test project type"
            };

            uow.ProjectTypes.Add(ProjectType.Create(projectTypeCreateParam));
            this.uow.Complete();

            var projectType        = this.uow.ProjectTypes.GetAll().First();
            var projectCreateParam = new ProjectCreateParam
            {
                Description = "Project description",
                Name        = "New project",
                ProjectType = projectType
            };

            uow.Projects.Add(Project.Create(projectCreateParam));
            this.uow.Complete();

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

            uow.Assignments.Add(Assignment.Create(assignmentCreateParam));
            this.uow.Complete();
        }
        public async Task <ServiceResult> Create([FromBody] ProjectCreateParam createParams)
        {
            await ProjectService.CreateAsync(createParams);

            return(await ServiceResult.IsSuccess());
        }
        private void CreateEntries()
        {
            var projectTypeCreateParam = new ProjectTypeCreateParam
            {
                Name        = "Test",
                Description = "Test project type"
            };

            uow.ProjectTypes.Add(ProjectType.Create(projectTypeCreateParam));
            this.uow.Complete();

            var projectType        = this.uow.ProjectTypes.GetAll().First();
            var projectCreateParam = new ProjectCreateParam
            {
                Description = "Project description",
                Name        = "New project",
                ProjectType = projectType
            };

            uow.Projects.Add(Project.Create(projectCreateParam));
            this.uow.Complete();

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

            uow.Assignments.Add(Assignment.Create(assignmentCreateParam));
            this.uow.Complete();
            var assignment = this.uow.Assignments.GetAll().First();
            var subtask    = Subtask.Create(new SubtaskCreateParam
            {
                Name        = "Test subtask",
                Description = "Test description",
                Priority    = EnumDefinition.SubtaskPriority.Medium
            });

            subtask.Assignment_Id = assignment.Id;
            subtask.Assignment    = assignment;
            this.uow.Subtasks.Add(subtask);
            this.uow.Complete();

            var entryCreateParam = new EntryCreateParam
            {
                Comment = "Test comment",
                Date    = DateTime.Now.Date,
                Started = DateTime.Now.AddHours(-2),
                Ended   = DateTime.Now.AddHours(-1),
                Name    = "Test entry",
                Project = project
            };

            for (int i = 0; i < 3; i++)
            {
                this.uow.Entries.Add(Entry.Create(entryCreateParam));
            }

            this.uow.Complete();
        }