Adds CreatorAlias User responses
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<UserTransactionDto>(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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<GetCreatorByAliasRequest>
|
||||
{
|
||||
public GetCreatorByAliasRequestValidator()
|
||||
{
|
||||
RuleFor(r => r.CreatorAlias)
|
||||
.NotNull().WithMessage("You must specify a creator-alias");
|
||||
}
|
||||
}
|
||||
|
||||
public class GetCreatorByAlias(
|
||||
IIdentityService identityService)
|
||||
: EndpointWithoutRequest<UserModel?>
|
||||
: Endpoint<GetCreatorByAliasRequest, UserModel?>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
@@ -16,13 +32,12 @@ public class GetCreatorByAlias(
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
GetCreatorByAliasRequest req,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var creatorAlias = Route<string>("CreatorAlias");
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(creatorAlias);
|
||||
|
||||
var user = await identityService.FindUserByCreatorAliasAsync(creatorAlias, ct);
|
||||
var user = await identityService.FindUserByCreatorAliasAsync(
|
||||
req.CreatorAlias,
|
||||
ct);
|
||||
|
||||
await SendAsync(user, cancellation: ct);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user