public IActionResult GetControlled([FromRoute] ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.Public)
        {
            var groups        = _groupCoreController.GetControlled(RequestingId, actorVisibilityFilter);
            var actorContract = groups.ToContractList();

            return(new ObjectResult(actorContract));
        }
        public IActionResult Get([FromRoute] string name, ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.Public)
        {
            var groups        = _groupCoreController.Search(name, actorVisibilityFilter);
            var actorContract = groups.ToContractList();

            return(new ObjectResult(actorContract));
        }
        public IActionResult Get([FromRoute] string name, bool exactMatch, ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.Public)
        {
            var users         = _userCoreController.Search(name, exactMatch, actorVisibilityFilter);
            var actorContract = users.ToContractList();

            return(new ObjectResult(actorContract));
        }
        //[ResponseType(typeof(UserResponse))]
        public IActionResult Get([FromRoute] int id, ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.Public)
        {
            var user          = _userCoreController.Get(id, actorVisibilityFilter);
            var actorContract = user.ToContract();

            return(new ObjectResult(actorContract));
        }
 public async Task <IActionResult> Get(ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.Public)
 {
     if ((await _authorizationService.AuthorizeAsync(User, Platform.AllId, HttpContext.ScopeItems(ClaimScope.Global))).Succeeded)
     {
         var users         = _userCoreController.GetAll(actorVisibilityFilter);
         var actorContract = users.ToContractList();
         return(new ObjectResult(actorContract));
     }
     return(Forbid());
 }
        /// <summary>
        /// Get a list of all the users
        /// </summary>
        /// <param name="requestingid">Id of the requesting actor, used to check if the actor has permissions to get the list with private members included </param>
        /// <returns></returns>
        public List<User> GetAll(ActorVisibilityFilter actorVisibilityFilter)
        {
            var users = _userController.Get();
            users = users.FilterVisibility(actorVisibilityFilter).ToList();

            users.ForEach(u => u.UserRelationshipCount = _relationshipController.GetRelationshipCount(u.Id, ActorType.User));
            users.ForEach(u => u.GroupRelationshipCount = _relationshipController.GetRelationshipCount(u.Id, ActorType.Group));

            _logger.LogInformation($"{users?.Count} Users");

            return users;
        }
        public List<User> Search(string name, bool exactMatch, ActorVisibilityFilter actorVisibilityFilter)
        {
            var users = _userController.Search(name, exactMatch);
            users = users.FilterVisibility(actorVisibilityFilter).ToList();

            users.ForEach(u => u.UserRelationshipCount = _relationshipController.GetRelationshipCount(u.Id, ActorType.User));
            users.ForEach(u => u.GroupRelationshipCount = _relationshipController.GetRelationshipCount(u.Id, ActorType.Group));

            _logger.LogInformation($"{users?.Count} Users for Name: {name}, ExactMatch: {exactMatch}");

            return users;
        }
Ejemplo n.º 8
0
        public List <Group> GetAll(ActorVisibilityFilter actorVisibilityFilter)
        {
            var groups = _groupDbController.Get();

            groups = groups.FilterVisibility(actorVisibilityFilter).ToList();

            groups.ForEach(g => g.UserRelationshipCount  = _relationshipController.GetRelationshipCount(g.Id, ActorType.User));
            groups.ForEach(g => g.GroupRelationshipCount = _relationshipController.GetRelationshipCount(g.Id, ActorType.Group));

            _logger.LogInformation($"{groups?.Count} Groups");

            return(groups);
        }
        /// <summary>
        /// Get relationships shared between an actor and other actor types
        /// </summary>
        /// <param name="actorId">The actor to get list of relationsips with</param>
        /// <param name="actorType">The tyoe of actor that relationship is shared with</param>
        /// <param name="actorVisibilityFilter">Filter to return related based on theri visibility setting</param>
        /// <returns></returns>
        public List <Actor> GetRelatedActors(int actorId, ActorType actorType, ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.Public)
        {
            var relationships = _relationshipDbController.GetRelatedActors(actorId, actorType);

            if ((actorVisibilityFilter & ActorVisibilityFilter.Private) == 0)
            {
                relationships = relationships.Where(r => !r.Private).ToList();
            }

            _logger.LogInformation($"{relationships?.Count} relationships for ActorId: {actorId}");

            return(relationships);
        }
Ejemplo n.º 10
0
        public List <Group> Search(string name, ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.Public)
        {
            var groups = _groupDbController.Get(name);

            groups = groups.FilterVisibility(actorVisibilityFilter).ToList();

            groups.ForEach(g => g.UserRelationshipCount  = _relationshipController.GetRelationshipCount(g.Id, ActorType.User));
            groups.ForEach(g => g.GroupRelationshipCount = _relationshipController.GetRelationshipCount(g.Id, ActorType.Group));


            _logger.LogInformation($"{groups?.Count} Groups for Name: {name}");

            return(groups);
        }
        protected string GetName(int id, ActorType actorType, ActorVisibilityFilter actorVisibilityFilter)
        {
            switch (actorType)
            {
            case ActorType.User:
                return(UserController.Get(id, actorVisibilityFilter).Name);

            case ActorType.Group:
                return(GroupController.Get(id, actorVisibilityFilter).Name);

            default:
                return(string.Empty);
            }
        }
Ejemplo n.º 12
0
        public Group Get(int id, ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.Public)
        {
            var group = _groupDbController.Get(id);

            group = group.FilterVisibility(actorVisibilityFilter);

            if (group != null)
            {
                group.UserRelationshipCount  = _relationshipController.GetRelationshipCount(group.Id, ActorType.User);
                group.GroupRelationshipCount = _relationshipController.GetRelationshipCount(group.Id, ActorType.Group);
            }

            _logger.LogInformation($"Group: {group?.Id} for Id: {id}");

            return(group);
        }
        public User Get(int id, ActorVisibilityFilter actorVisibilityFilter)
        {
            var user = _userController.Get(id);
            user = user.FilterVisibility(actorVisibilityFilter);

            if (user == null)
            {
                return null;
            }

            user.UserRelationshipCount = _relationshipController.GetRelationshipCount(user.Id, ActorType.User);
            user.GroupRelationshipCount = _relationshipController.GetRelationshipCount(user.Id, ActorType.Group);

            _logger.LogInformation($"User: {user?.Id} for Id: {id}");

            return user;
        }
Ejemplo n.º 14
0
        public List <Group> GetControlled(int userId, ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.All)
        {
            var groups = GetAll(actorVisibilityFilter);

            var groupsWhereControlled = groups
                                        .Where(g => IsGroupController(userId, g.Id))
                                        .ToList();

            groups.ForEach(g =>
            {
                g.UserRelationshipCount  = _relationshipController.GetRelationshipCount(g.Id, ActorType.User);
                g.GroupRelationshipCount = _relationshipController.GetRelationshipCount(g.Id, ActorType.Group);
            });

            _logger.LogInformation($"{groups.Count} Groups");

            return(groupsWhereControlled);
        }
Ejemplo n.º 15
0
        public Actor Get(int actorId, ActorVisibilityFilter actorVisibilityFilter = ActorVisibilityFilter.Public)
        {
            var actor = _actorDbController.Get(actorId);

            return(actor.FilterVisibility(actorVisibilityFilter));
        }
 public static T FilterVisibility <T>(this T actor, ActorVisibilityFilter filter) where T : Actor
 {
     return(actor != null && IsNotFilteredOut(actor, filter) ? actor : null);
 }
 public static bool IsNotFilteredOut(Actor actor, ActorVisibilityFilter filter)
 {
     // if private should be included OR this is not private
     return((filter & ActorVisibilityFilter.Private) != 0 || !actor.Private);
 }
 public static IEnumerable <T> FilterVisibility <T>(this List <T> actors, ActorVisibilityFilter filter) where T : Actor
 {
     return(actors
            .Where(a => IsNotFilteredOut(a, filter)));
 }