private ProjectUserRole AddUserRole(ProjectUser projectUser, ProjectRole projectRole)
        {
            var projectUserRole = new ProjectUserRole();

            projectUserRole.ProjectUser = projectUser;
            projectUserRole.ProjectRole = projectRole;
            Repository.Add(projectUserRole);
            return(projectUserRole);
        }
示例#2
0
 public Task <User> AddProjectMembershipAsync(User user, string projectId, ProjectUserRole role, IDictionary <string, string> properties)
 {
     return(AddProjectMembershipAsync(user, new ProjectMembership
     {
         ProjectId = projectId,
         Role = role,
         Properties = properties ?? new Dictionary <string, string>()
     }));
 }
 public async Task <bool> AddProjectUserRole(ProjectUserRole pur)
 {
     try
     {
         await _db.Set <ProjectUserRole>().AddAsync(pur);
     }
     catch (Exception e)
     {
         return(false);
     }
     return(true);
 }
示例#4
0
        public ProjectUserRoleDTO GetLink(int?id)
        {
            ProjectUserRole link = Database.Links.Get(id.Value);

            if (link != null)
            {
                var mapper = new MapperConfiguration(cfg => cfg.CreateMap <ProjectUserRole, ProjectUserRoleDTO>()).CreateMapper();
                return(mapper.Map <ProjectUserRole, ProjectUserRoleDTO>(link));
            }
            else
            {
                throw new Exception("Not Found!");
            }
        }
示例#5
0
        public bool Delete(int?id)
        {
            ProjectUserRole link = Database.Links.Get(id.Value);

            if (link != null)
            {
                Database.Links.Delete(id.Value);
                Database.Save();
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#6
0
    public static User EnsureProjectMembership(this User user, string projectId, ProjectUserRole role, IDictionary <string, string> properties = null)
    {
        if (user is null)
        {
            throw new ArgumentNullException(nameof(user));
        }
        if (projectId is null)
        {
            throw new ArgumentNullException(nameof(projectId));
        }

        return(user.EnsureProjectMembership(new ProjectMembership
        {
            ProjectId = projectId,
            Role = role,
            Properties = properties ?? new Dictionary <string, string>()
        }));
    }
示例#7
0
 public static string PolicyRoleName(this ProjectUserRole role)
 => $"Project_{role}";
示例#8
0
 internal static Guid ToRoleDefinitionId(this ProjectUserRole projectUserRole) => projectUserRole switch
 {
示例#9
0
 public static string AuthPolicy(this ProjectUserRole role)
 => $"Project{role}";