From 8a43ee25abcd9a90258ee8ca9f0920303e6c4fcb Mon Sep 17 00:00:00 2001 From: Tino Hager Date: Tue, 2 Jan 2024 16:32:07 +0100 Subject: [PATCH] fix mapping --- .../Controllers/AuthenticationController.cs | 2 +- .../Nager.Authentication.AspNet.csproj | 2 +- .../InMemoryUserRepository.cs | 2 +- .../Nager.Authentication.csproj | 2 +- .../Services/UserManagementService.cs | 25 +++++++------------ 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/Nager.Authentication.AspNet/Controllers/AuthenticationController.cs b/src/Nager.Authentication.AspNet/Controllers/AuthenticationController.cs index 3f755f0..cc00e51 100644 --- a/src/Nager.Authentication.AspNet/Controllers/AuthenticationController.cs +++ b/src/Nager.Authentication.AspNet/Controllers/AuthenticationController.cs @@ -140,7 +140,7 @@ public async Task> AuthenticateAsync( }; var authenticationStatus = await this._userAuthenticationService.ValidateCredentialsAsync(authenticationRequest, cancellationToken); - this._logger.LogInformation($"{nameof(AuthenticateAsync)} - EmailAddress:{request.EmailAddress} AuthenticationStatus:{authenticationStatus}"); + this._logger.LogInformation($"{nameof(AuthenticateAsync)} - EmailAddress:{request.EmailAddress}, AuthenticationStatus:{authenticationStatus}"); switch (authenticationStatus) { diff --git a/src/Nager.Authentication.AspNet/Nager.Authentication.AspNet.csproj b/src/Nager.Authentication.AspNet/Nager.Authentication.AspNet.csproj index 0ae5459..14d6c9c 100644 --- a/src/Nager.Authentication.AspNet/Nager.Authentication.AspNet.csproj +++ b/src/Nager.Authentication.AspNet/Nager.Authentication.AspNet.csproj @@ -18,7 +18,7 @@ net8.0;net7.0;net6.0 enable - 1.1.0 + 1.1.1 diff --git a/src/Nager.Authentication.InMemoryRepository/InMemoryUserRepository.cs b/src/Nager.Authentication.InMemoryRepository/InMemoryUserRepository.cs index dd0726b..9ec4d4f 100644 --- a/src/Nager.Authentication.InMemoryRepository/InMemoryUserRepository.cs +++ b/src/Nager.Authentication.InMemoryRepository/InMemoryUserRepository.cs @@ -36,8 +36,8 @@ public Task QueryAsync( { qurey = qurey.Where(predicate); } - var items = qurey.Take(take).Skip(skip).ToArray(); + var items = qurey.OrderBy(o => o.Id).Take(take).Skip(skip).ToArray(); return Task.FromResult(items); } diff --git a/src/Nager.Authentication/Nager.Authentication.csproj b/src/Nager.Authentication/Nager.Authentication.csproj index 514883e..84d150f 100644 --- a/src/Nager.Authentication/Nager.Authentication.csproj +++ b/src/Nager.Authentication/Nager.Authentication.csproj @@ -20,7 +20,7 @@ enable net8.0;net7.0;net6.0 - 1.1.0 + 1.1.1 diff --git a/src/Nager.Authentication/Services/UserManagementService.cs b/src/Nager.Authentication/Services/UserManagementService.cs index 30f2557..80c74cb 100644 --- a/src/Nager.Authentication/Services/UserManagementService.cs +++ b/src/Nager.Authentication/Services/UserManagementService.cs @@ -24,22 +24,6 @@ public UserManagementService( this._userRepository = userRepository; } - public async Task QueryAsync( - int take, - int skip, - CancellationToken cancellationToken = default) - { - var items = await this._userRepository.QueryAsync(take, skip, cancellationToken: cancellationToken); - return items.OrderBy(user => user.EmailAddress).Select(userEntity => new UserInfo - { - Id = userEntity.Id, - EmailAddress = userEntity.EmailAddress, - Firstname = userEntity.Firstname, - Lastname = userEntity.Lastname, - Roles = RoleHelper.GetRoles(userEntity.RolesData) - }).ToArray(); - } - private UserInfo MapUserInfo(UserEntity userEntity) { return new UserInfo @@ -54,6 +38,15 @@ private UserInfo MapUserInfo(UserEntity userEntity) }; } + public async Task QueryAsync( + int take, + int skip, + CancellationToken cancellationToken = default) + { + var items = await this._userRepository.QueryAsync(take, skip, cancellationToken: cancellationToken); + return items.OrderBy(user => user.EmailAddress).Select(this.MapUserInfo).ToArray(); + } + public async Task GetByIdAsync( string id, CancellationToken cancellationToken = default)