public PipelineRole GetRoleInProject(Guid projectId)
        {
            if (ProjectUsers == null)
            {
                ProjectUsers = new List <ProjectUser>();
            }

            ProjectUser projectUser = ProjectUsers.FirstOrDefault(x => x.ProjectId == projectId);

            if (projectUser == null)
            {
                return(PipelineRole.None);
            }

            return(projectUser.Role);
        }
            public static ProjectUser Create(Guid projectId, string userId, PipelineRole role, string createdBy)
            {
                var entity = new ProjectUser()
                {
                    ProjectUserId = Guid.NewGuid(),
                    ProjectId     = projectId,
                    UserId        = userId,
                    CreatedBy     = createdBy,
                    Status        = EntityStatus.Active,
                    Role          = role
                };

                var validationResult = new DataValidatorManager <ProjectUser>().Build().Validate(entity);

                if (!validationResult.IsValid)
                {
                    throw new ApplicationException(validationResult.Errors);
                }

                return(entity);
            }