public async Task <IActionResult> RegisterAsync([FromQuery] GetUsersQueryDto query) { query.UserId = User.GetUserId(); var result = await _userService.GetByQueryAsync(query); return(Json(result)); }
public override async Task GetUsers(GetUsersQueryDto request, IServerStreamWriter <UserDto> responseStream, ServerCallContext context) { var users = db.Users.AsNoTracking(); if (request.Ids.Any()) { users = users.Where(u => request.Ids.Select(i => Guid.Parse(i)).Contains(u.Id)); } await foreach (var user in users.AsAsyncEnumerable()) { await responseStream.WriteAsync(user.ToTransfer()); } }
public async Task <IImmutableList <GetUserDto> > GetByQueryAsync(GetUsersQueryDto query, CancellationToken ct = default) { _logger.LogInformation("Get users by query {@UserQuery}", query); GetUsersQuery dbQuery = _mapper.Map <GetUsersQuery>(query); ICollection <User> users = await _unitOfWork.UserRepository.GetByQueryAsync(dbQuery, ct); ICollection <UserContact> userContacts = await _unitOfWork.UserContactRepository.GetUserContactsAsync(query.UserId, ct); users = users.Where(t => userContacts.All(c => c.ContactId != t.Id)).ToList(); return(_mapper.Map <ICollection <GetUserDto> >(users).ToImmutableList()); }