#27 get last receipt, get minimalUser, get my user

This commit is contained in:
Dominic Villemure
2024-05-12 16:40:24 -04:00
parent 3f20563850
commit 5161e3a91a
17 changed files with 216 additions and 24 deletions

View File

@@ -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,

View File

@@ -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; } = [];
}

View File

@@ -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;
}
}

View File

@@ -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;
}