diff --git a/src/Application/Common/Models/UserModel.cs b/src/Application/Common/Models/UserModel.cs index ccff715..d7324a1 100644 --- a/src/Application/Common/Models/UserModel.cs +++ b/src/Application/Common/Models/UserModel.cs @@ -5,6 +5,7 @@ namespace Hutopy.Application.Common.Models; public class UserModel { public string Id { get; set; } = string.Empty; + public string? CreatorAlias { get; set; } public string UserName { get; set; } = string.Empty; public string FirstName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty; diff --git a/src/Application/Users/Queries/GetCurrentUser/GetCurrentUser.cs b/src/Application/Users/Queries/GetCurrentUser/GetCurrentUser.cs index f8cc1ab..6a90585 100644 --- a/src/Application/Users/Queries/GetCurrentUser/GetCurrentUser.cs +++ b/src/Application/Users/Queries/GetCurrentUser/GetCurrentUser.cs @@ -16,7 +16,8 @@ public class GetCurrentUserQueryHandler( var identityUser = await identityService.GetCurrentUserAsync(); var currentUserId = Guid.Parse(identityUser!.Id!); - var transactions = await context.UserTransactions + var transactions = await context + .UserTransactions .Where(x => x.ApplicationUserId == currentUserId.ToString()) .OrderBy(x => x.LastModified) .ProjectTo(mapper.ConfigurationProvider) @@ -28,18 +29,19 @@ public class GetCurrentUserQueryHandler( var user = new UserDto { Id = currentUserId, - FirstName = identityUser.FirstName ?? "", - LastName = identityUser.LastName ?? "", - UserName = identityUser.UserName ?? "", - Occupation = identityUser.Occupation ?? "", - PhoneNumber = identityUser.PhoneNumber ?? "", - Email = identityUser.Email ?? "", - BirthDate = identityUser.BirthDate ?? "", - Country = identityUser.Country ?? "", - City = identityUser.City ?? "", - Address = identityUser.Address ?? "", - About = identityUser.About ?? "", - Description = identityUser.Description ?? "", + FirstName = identityUser.FirstName, + LastName = identityUser.LastName, + UserName = identityUser.UserName, + CreatorAlias= identityUser.CreatorAlias, + Occupation = identityUser.Occupation, + PhoneNumber = identityUser.PhoneNumber, + Email = identityUser.Email, + BirthDate = identityUser.BirthDate, + Country = identityUser.Country, + City = identityUser.City, + Address = identityUser.Address, + About = identityUser.About, + Description = identityUser.Description, SocialNetworks = identityUser.SocialNetworks, ProfileColors = identityUser.ProfileColors, StoredDataUrls = identityUser.StoredDataUrls, diff --git a/src/Application/Users/Queries/GetCurrentUser/UserDto.cs b/src/Application/Users/Queries/GetCurrentUser/UserDto.cs index 23dfaa8..4964a3b 100644 --- a/src/Application/Users/Queries/GetCurrentUser/UserDto.cs +++ b/src/Application/Users/Queries/GetCurrentUser/UserDto.cs @@ -7,6 +7,7 @@ public class UserDto public Guid Id { get; init; } public required string FirstName { get; init; } public required string LastName { get; init; } + public string? CreatorAlias { get; set; } public string UserName { get; init; } = string.Empty; public string Occupation { get; init; } = string.Empty; public string Email { get; init; } = string.Empty; diff --git a/src/Application/Users/Queries/GetUser/UserDto.cs b/src/Application/Users/Queries/GetUser/UserDto.cs index 509743d..6c1dc13 100644 --- a/src/Application/Users/Queries/GetUser/UserDto.cs +++ b/src/Application/Users/Queries/GetUser/UserDto.cs @@ -7,6 +7,7 @@ public class UserDto public required string Id { get; init; } public required string FirstName { get; init; } public required string LastName { get; init; } + public string CreatorAlias { get; set; } public required string UserName { get; init; } = String.Empty; public required string Occupation { get; init; } = String.Empty; diff --git a/src/Infrastructure/Identity/IdentityService.cs b/src/Infrastructure/Identity/IdentityService.cs index 4842668..747fff4 100644 --- a/src/Infrastructure/Identity/IdentityService.cs +++ b/src/Infrastructure/Identity/IdentityService.cs @@ -38,6 +38,7 @@ public class IdentityService( var userModel = new UserModel() { Id = response.Id, + CreatorAlias = response.CreatorAlias, UserName = response.UserName ?? string.Empty, FirstName = response.FirstName, LastName = response.LastName, @@ -189,6 +190,7 @@ public class IdentityService( var userModel = new UserModel { Id = response.Id, + CreatorAlias = response.CreatorAlias, UserName = response.UserName ?? string.Empty, FirstName = response.FirstName, LastName = response.LastName, @@ -238,6 +240,7 @@ public class IdentityService( var userModel = new UserModel { Id = response.Id, + CreatorAlias = response.CreatorAlias, UserName = response.UserName ?? string.Empty, FirstName = response.FirstName, LastName = response.LastName, diff --git a/src/Web/Features/Creators/Handlers/GetCreatorByAlias.cs b/src/Web/Features/Creators/Handlers/GetCreatorByAlias.cs index b606a13..0c798e9 100644 --- a/src/Web/Features/Creators/Handlers/GetCreatorByAlias.cs +++ b/src/Web/Features/Creators/Handlers/GetCreatorByAlias.cs @@ -1,12 +1,28 @@ using FastEndpoints; +using FluentValidation; using Hutopy.Application.Common.Interfaces; using Hutopy.Application.Common.Models; namespace Hutopy.Web.Features.Creators.Handlers; +public sealed class GetCreatorByAliasRequest +{ + public string CreatorAlias { get; set; } +} + +public sealed class GetCreatorByAliasRequestValidator + : Validator +{ + public GetCreatorByAliasRequestValidator() + { + RuleFor(r => r.CreatorAlias) + .NotNull().WithMessage("You must specify a creator-alias"); + } +} + public class GetCreatorByAlias( IIdentityService identityService) - : EndpointWithoutRequest + : Endpoint { public override void Configure() { @@ -16,13 +32,12 @@ public class GetCreatorByAlias( } public override async Task HandleAsync( + GetCreatorByAliasRequest req, CancellationToken ct) { - var creatorAlias = Route("CreatorAlias"); - - ArgumentException.ThrowIfNullOrEmpty(creatorAlias); - - var user = await identityService.FindUserByCreatorAliasAsync(creatorAlias, ct); + var user = await identityService.FindUserByCreatorAliasAsync( + req.CreatorAlias, + ct); await SendAsync(user, cancellation: ct); }