Example #1
0
        public async Task <List <DisplayUserDto> > GetSuggestedUsers(GetSuggestedUsers command)
        {
            if (string.IsNullOrWhiteSpace(command.SearchLetters) || command.SearchLetters.Length < 3)
            {
                throw new AppException("You need to specify at least three letters to search suggested users", AppErrorCode.BAD_INPUT);
            }
            await _administratorService.ValidateAtLeastModerator(command.UserId, command.GroupId);

            var foundUsers = _userRepository.GetSuggestedAsync(command.SearchLetters, command.GroupId).Take(10);

            return(_mapper.ProjectTo <DisplayUserDto>(foundUsers).ToList());
        }
Example #2
0
        public async Task <ActionResult <List <DisplayUserDto> > > GetSuggestedUsers(Guid groupId, [FromQuery] GetSuggestedUsers command)
        {
            command.UserId  = User.GetUserId();
            command.GroupId = groupId;
            var data = await _userService.GetSuggestedUsers(command);

            return(Ok(data));
        }