Ejemplo n.º 1
0
        public void ChangeProjectRoleNameTest()
        {
            ProjectRoleService projectRoleService = new ProjectRoleService(uow, new Map <ProjectRole, ProjectRoleDTO>());

            var            projectRole = projectRoleService.CreateProjectRole("abc");
            ProjectRoleDTO actual      = projectRoleService.GetProjectRoleById(projectRole.Id);

            projectRoleService.ChangeProjectRoleName(actual.Id, "cba");
            ProjectRoleDTO expected = projectRoleService.GetProjectRoleById(projectRole.Id);

            Assert.IsTrue(expected.ProjectRoleName == "cba");

            projectRoleService.DeleteProjectRoleById(actual.Id);
        }
Ejemplo n.º 2
0
        public void CreateProjectRoleTest()
        {
            ProjectRoleService projectRoleService = new ProjectRoleService(uow, new Map <ProjectRole, ProjectRoleDTO>());

            var            projectRole = projectRoleService.CreateProjectRole("abc");
            ProjectRoleDTO actual      = projectRoleService.GetProjectRoleById(projectRole.Id);
            ProjectRoleDTO expected    = new ProjectRoleDTO
            {
                Id = actual.Id,
                ProjectRoleName = "abc"
            };

            Assert.IsTrue(actual.Id == expected.Id && actual.ProjectRoleName == expected.ProjectRoleName);

            projectRoleService.DeleteProjectRoleById(actual.Id);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> CreatePorjectRole([FromBody] ProjectRoleDTO model)
        {
            var exist = await _context.ProjectRoles.AnyAsync(c => c.Name == model.Name);

            if (exist)
            {
                return(await Task.FromResult(new BadRequestResult()));
            }

            var role = new ProjectRole
            {
                Name = model.Name
            };

            await _context.ProjectRoles.AddAsync(role);

            await _context.SaveChangesAsync();

            return(await Task.FromResult(new OkObjectResult(role)));
        }