#27 get last receipt, get minimalUser, get my user
This commit is contained in:
@@ -18,12 +18,11 @@ public class GetCurrentUserQueryHandler(
|
||||
var currentUserId = new Guid(identityUser?.Id ?? "");
|
||||
|
||||
var transactions = await context.UserTransactions
|
||||
.Where(x => x.Id == currentUserId)
|
||||
.Where(x => x.ApplicationUserId == currentUserId.ToString())
|
||||
.OrderBy(x => x.LastModified)
|
||||
.ProjectTo<UserTransactionDto>(mapper.ConfigurationProvider)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
|
||||
var user = new UserDto()
|
||||
{
|
||||
Id = currentUserId,
|
||||
@@ -7,6 +7,7 @@ public class UserDto
|
||||
public required string FirstName { get; init; }
|
||||
|
||||
public required string LastName { get; init; }
|
||||
public string UserName { get; init; } = String.Empty;
|
||||
|
||||
public List<UserTransactionDto> UserTransactions { get; init; } = [];
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Hutopy.Domain.Interfaces;
|
||||
|
||||
namespace Hutopy.Application.Users.Queries.GetMinimalUser;
|
||||
|
||||
public record GetMinimalUserQuery : IRequest<MinimalUserDto>
|
||||
{
|
||||
public string UserId { get; set; } = string.Empty;
|
||||
};
|
||||
|
||||
public class GetMinimalUserQueryHandler(
|
||||
IUserService userService
|
||||
)
|
||||
: IRequestHandler<GetMinimalUserQuery, MinimalUserDto>
|
||||
{
|
||||
public async Task<MinimalUserDto> Handle(GetMinimalUserQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var identityUser = await userService.FindUserByIdAsync(request.UserId);
|
||||
|
||||
var user = new MinimalUserDto()
|
||||
{
|
||||
FirstName = identityUser?.FirstName ?? "",
|
||||
LastName = identityUser?.LastName ?? "",
|
||||
UserName = identityUser?.UserName ?? ""
|
||||
};
|
||||
|
||||
return user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Hutopy.Application.Users.Queries.GetMinimalUser;
|
||||
|
||||
public class MinimalUserDto
|
||||
{
|
||||
public required string FirstName { get; init; }
|
||||
public required string LastName { get; init; }
|
||||
public string UserName { get; init; } = String.Empty;
|
||||
}
|
||||
Reference in New Issue
Block a user