Adds CreatorAlias User responses
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Hutopy.Application.Common.Models;
|
|||||||
public class UserModel
|
public class UserModel
|
||||||
{
|
{
|
||||||
public string Id { get; set; } = string.Empty;
|
public string Id { get; set; } = string.Empty;
|
||||||
|
public string? CreatorAlias { get; set; }
|
||||||
public string UserName { get; set; } = string.Empty;
|
public string UserName { get; set; } = string.Empty;
|
||||||
public string FirstName { get; set; } = string.Empty;
|
public string FirstName { get; set; } = string.Empty;
|
||||||
public string LastName { get; set; } = string.Empty;
|
public string LastName { get; set; } = string.Empty;
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public class GetCurrentUserQueryHandler(
|
|||||||
var identityUser = await identityService.GetCurrentUserAsync();
|
var identityUser = await identityService.GetCurrentUserAsync();
|
||||||
var currentUserId = Guid.Parse(identityUser!.Id!);
|
var currentUserId = Guid.Parse(identityUser!.Id!);
|
||||||
|
|
||||||
var transactions = await context.UserTransactions
|
var transactions = await context
|
||||||
|
.UserTransactions
|
||||||
.Where(x => x.ApplicationUserId == currentUserId.ToString())
|
.Where(x => x.ApplicationUserId == currentUserId.ToString())
|
||||||
.OrderBy(x => x.LastModified)
|
.OrderBy(x => x.LastModified)
|
||||||
.ProjectTo<UserTransactionDto>(mapper.ConfigurationProvider)
|
.ProjectTo<UserTransactionDto>(mapper.ConfigurationProvider)
|
||||||
@@ -28,18 +29,19 @@ public class GetCurrentUserQueryHandler(
|
|||||||
var user = new UserDto
|
var user = new UserDto
|
||||||
{
|
{
|
||||||
Id = currentUserId,
|
Id = currentUserId,
|
||||||
FirstName = identityUser.FirstName ?? "",
|
FirstName = identityUser.FirstName,
|
||||||
LastName = identityUser.LastName ?? "",
|
LastName = identityUser.LastName,
|
||||||
UserName = identityUser.UserName ?? "",
|
UserName = identityUser.UserName,
|
||||||
Occupation = identityUser.Occupation ?? "",
|
CreatorAlias= identityUser.CreatorAlias,
|
||||||
PhoneNumber = identityUser.PhoneNumber ?? "",
|
Occupation = identityUser.Occupation,
|
||||||
Email = identityUser.Email ?? "",
|
PhoneNumber = identityUser.PhoneNumber,
|
||||||
BirthDate = identityUser.BirthDate ?? "",
|
Email = identityUser.Email,
|
||||||
Country = identityUser.Country ?? "",
|
BirthDate = identityUser.BirthDate,
|
||||||
City = identityUser.City ?? "",
|
Country = identityUser.Country,
|
||||||
Address = identityUser.Address ?? "",
|
City = identityUser.City,
|
||||||
About = identityUser.About ?? "",
|
Address = identityUser.Address,
|
||||||
Description = identityUser.Description ?? "",
|
About = identityUser.About,
|
||||||
|
Description = identityUser.Description,
|
||||||
SocialNetworks = identityUser.SocialNetworks,
|
SocialNetworks = identityUser.SocialNetworks,
|
||||||
ProfileColors = identityUser.ProfileColors,
|
ProfileColors = identityUser.ProfileColors,
|
||||||
StoredDataUrls = identityUser.StoredDataUrls,
|
StoredDataUrls = identityUser.StoredDataUrls,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public class UserDto
|
|||||||
public Guid Id { get; init; }
|
public Guid Id { get; init; }
|
||||||
public required string FirstName { get; init; }
|
public required string FirstName { get; init; }
|
||||||
public required string LastName { get; init; }
|
public required string LastName { get; init; }
|
||||||
|
public string? CreatorAlias { get; set; }
|
||||||
public string UserName { get; init; } = string.Empty;
|
public string UserName { get; init; } = string.Empty;
|
||||||
public string Occupation { get; init; } = string.Empty;
|
public string Occupation { get; init; } = string.Empty;
|
||||||
public string Email { 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 Id { get; init; }
|
||||||
public required string FirstName { get; init; }
|
public required string FirstName { get; init; }
|
||||||
public required string LastName { get; init; }
|
public required string LastName { get; init; }
|
||||||
|
public string CreatorAlias { get; set; }
|
||||||
public required string UserName { get; init; } = String.Empty;
|
public required string UserName { get; init; } = String.Empty;
|
||||||
public required string Occupation { get; init; } = String.Empty;
|
public required string Occupation { get; init; } = String.Empty;
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public class IdentityService(
|
|||||||
var userModel = new UserModel()
|
var userModel = new UserModel()
|
||||||
{
|
{
|
||||||
Id = response.Id,
|
Id = response.Id,
|
||||||
|
CreatorAlias = response.CreatorAlias,
|
||||||
UserName = response.UserName ?? string.Empty,
|
UserName = response.UserName ?? string.Empty,
|
||||||
FirstName = response.FirstName,
|
FirstName = response.FirstName,
|
||||||
LastName = response.LastName,
|
LastName = response.LastName,
|
||||||
@@ -189,6 +190,7 @@ public class IdentityService(
|
|||||||
var userModel = new UserModel
|
var userModel = new UserModel
|
||||||
{
|
{
|
||||||
Id = response.Id,
|
Id = response.Id,
|
||||||
|
CreatorAlias = response.CreatorAlias,
|
||||||
UserName = response.UserName ?? string.Empty,
|
UserName = response.UserName ?? string.Empty,
|
||||||
FirstName = response.FirstName,
|
FirstName = response.FirstName,
|
||||||
LastName = response.LastName,
|
LastName = response.LastName,
|
||||||
@@ -238,6 +240,7 @@ public class IdentityService(
|
|||||||
var userModel = new UserModel
|
var userModel = new UserModel
|
||||||
{
|
{
|
||||||
Id = response.Id,
|
Id = response.Id,
|
||||||
|
CreatorAlias = response.CreatorAlias,
|
||||||
UserName = response.UserName ?? string.Empty,
|
UserName = response.UserName ?? string.Empty,
|
||||||
FirstName = response.FirstName,
|
FirstName = response.FirstName,
|
||||||
LastName = response.LastName,
|
LastName = response.LastName,
|
||||||
|
|||||||
@@ -1,12 +1,28 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
|
using FluentValidation;
|
||||||
using Hutopy.Application.Common.Interfaces;
|
using Hutopy.Application.Common.Interfaces;
|
||||||
using Hutopy.Application.Common.Models;
|
using Hutopy.Application.Common.Models;
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Creators.Handlers;
|
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(
|
public class GetCreatorByAlias(
|
||||||
IIdentityService identityService)
|
IIdentityService identityService)
|
||||||
: EndpointWithoutRequest<UserModel?>
|
: Endpoint<GetCreatorByAliasRequest, UserModel?>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -16,13 +32,12 @@ public class GetCreatorByAlias(
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(
|
public override async Task HandleAsync(
|
||||||
|
GetCreatorByAliasRequest req,
|
||||||
CancellationToken ct)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
var creatorAlias = Route<string>("CreatorAlias");
|
var user = await identityService.FindUserByCreatorAliasAsync(
|
||||||
|
req.CreatorAlias,
|
||||||
ArgumentException.ThrowIfNullOrEmpty(creatorAlias);
|
ct);
|
||||||
|
|
||||||
var user = await identityService.FindUserByCreatorAliasAsync(creatorAlias, ct);
|
|
||||||
|
|
||||||
await SendAsync(user, cancellation: ct);
|
await SendAsync(user, cancellation: ct);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user