/// <summary> /// Gets the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public object Get(GetUsers request) { var users = _userManager.Users; if (request.IsDisabled.HasValue) { users = users.Where(i => i.Configuration.IsDisabled == request.IsDisabled.Value); } if (request.IsHidden.HasValue) { users = users.Where(i => i.Configuration.IsHidden == request.IsHidden.Value); } if (request.IsGuest.HasValue) { users = users.Where(i => (i.ConnectLinkType.HasValue && i.ConnectLinkType.Value == UserLinkType.Guest) == request.IsGuest.Value); } var result = users .OrderBy(u => u.Name) .Select(i => _userManager.GetUserDto(i, Request.RemoteIp)) .ToList(); return(ToOptimizedSerializedResultUsingCache(result)); }
/// <summary> /// Gets the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public object Get(GetUsers request) { var dtoBuilder = new DtoBuilder(Logger, _libraryManager); var tasks = _userManager.Users.OrderBy(u => u.Name).Select(dtoBuilder.GetUserDto).ToArray(); var task = Task.WhenAll(tasks); return(ToOptimizedResult(task.Result)); }
/// <summary> /// Gets the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public object Get(GetUsers request) { var users = _userManager.Users; if (request.IsDisabled.HasValue) { users = users.Where(i => i.Configuration.IsDisabled == request.IsDisabled.Value); } if (request.IsHidden.HasValue) { users = users.Where(i => i.Configuration.IsHidden == request.IsHidden.Value); } var tasks = users.OrderBy(u => u.Name).Select(_dtoService.GetUserDto).Select(i => i.Result); return(ToOptimizedResult(tasks.ToList())); }
private object Get(GetUsers request, bool filterByDevice, bool filterByNetwork) { var users = _userManager.Users; if (request.IsDisabled.HasValue) { users = users.Where(i => i.Policy.IsDisabled == request.IsDisabled.Value); } if (request.IsHidden.HasValue) { users = users.Where(i => i.Policy.IsHidden == request.IsHidden.Value); } if (request.IsGuest.HasValue) { users = users.Where(i => (i.ConnectLinkType.HasValue && i.ConnectLinkType.Value == UserLinkType.Guest) == request.IsGuest.Value); } if (filterByDevice) { var deviceId = _authContext.GetAuthorizationInfo(Request).DeviceId; if (!string.IsNullOrWhiteSpace(deviceId)) { users = users.Where(i => _deviceManager.CanAccessDevice(i, deviceId)); } } if (filterByNetwork) { if (!_networkManager.IsInLocalNetwork(Request.RemoteIp)) { users = users.Where(i => i.Policy.EnableRemoteAccess); } } var result = users .OrderBy(u => u.Name) .Select(i => _userManager.GetUserDto(i, Request.RemoteIp)) .ToArray(); return(ToOptimizedResult(result)); }
private object Get(GetUsers request, bool filterByDevice) { var users = _userManager.Users; if (request.IsDisabled.HasValue) { users = users.Where(i => i.Policy.IsDisabled == request.IsDisabled.Value); } if (request.IsHidden.HasValue) { users = users.Where(i => i.Policy.IsHidden == request.IsHidden.Value); } if (request.IsGuest.HasValue) { users = users.Where(i => (i.ConnectLinkType.HasValue && i.ConnectLinkType.Value == UserLinkType.Guest) == request.IsGuest.Value); } if (filterByDevice) { var deviceId = AuthorizationContext.GetAuthorizationInfo(Request).DeviceId; if (!string.IsNullOrWhiteSpace(deviceId)) { users = users.Where(i => _deviceManager.CanAccessDevice(i.Id.ToString("N"), deviceId)); } } var result = users .OrderBy(u => u.Name) .Select(i => _userManager.GetUserDto(i, Request.RemoteIp)) .ToList(); return(ToOptimizedSerializedResultUsingCache(result)); }
/// <summary> /// Gets the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>System.Object.</returns> public object Get(GetUsers request) { return(Get(request, false, false)); }