public void AddUsertoProject(string projectId, string userId, string roleName = SystemRoles.DashboardOnly) { CheckAuthentication(); var projectRole = FindRoleByTitle(projectId, roleName); if (projectRole == null) { throw new ArgumentException(string.Format("No role found for role name: {0}", roleName)); } var url = Url.Combine(Config.Url, Constants.PROJECTS_URI, projectId, Constants.PROJECT_USERS_SUFFIX); var payload = new ProjectUserRequest { User = new ProjectUserRequest.UserRequest { Content = new ProjectUserRequest.UserRequest.ContentRequest { Status = "ENABLED", UserRoles = new List<string> { Url.Combine(Constants.PROJECTS_URI, projectId, Constants.PROJECT_ROLES_SUFFIX, projectRole.RoleId) } }, Links = new ProjectUserRequest.UserRequest.LinksRequest { Self = Url.Combine(Constants.PROFILE_URI, userId) } } }; PostRequest(url, payload); }
public void UpdateProjectUserAccess(string projectId, string profileId, bool enabled, string roleName = SystemRoles.DashboardOnly) { CheckAuthentication(); var role = FindRoleByTitle(projectId, roleName); var url = Url.Combine(Config.Url, Constants.PROJECTS_URI, projectId, Constants.PROJECT_USERS_SUFFIX); var payload = new ProjectUserRequest { User = new ProjectUserRequest.UserRequest { Content = new ProjectUserRequest.UserRequest.ContentRequest { Status = (enabled) ? "ENABLED" : "DISABLED", UserRoles = new List<string>{role.Meta.Uri} }, Links = new ProjectUserRequest.UserRequest.LinksRequest { Self = Url.Combine(Constants.PROFILE_URI, profileId) } } }; PostRequest(url, payload); }