This commit is contained in:
2026-05-14 01:05:07 +02:00
parent 8ad203c974
commit 8cda85e562
60 changed files with 129 additions and 137 deletions
@@ -2,22 +2,22 @@ using Ardalis.Result;
using Mediator;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Musify.Application.Contracts.Infrastructure;
using Musify.Application.Abstractions.Infrastructure;
using Musify.Application.Users.Commands;
using Musify.Application.Users.Responses;
namespace Musify.Application.Users.Handlers
{
public class CreateUserCommandHandler(IDatabase database, ILogger<CreateUserCommandHandler> logger)
: ICommandHandler<CreateUserCommand, Result<UserResponse> >
: ICommandHandler<CreateUserCommand, Result<UserApplicationResponse> >
{
public async ValueTask<Result<UserResponse>> Handle(CreateUserCommand request, CancellationToken cancellationToken)
public async ValueTask<Result<UserApplicationResponse>> Handle(CreateUserCommand request, CancellationToken cancellationToken)
{
var userExists = await database.Users.AnyAsync(u => u.Id == request.Id, cancellationToken);
if (userExists)
{
logger.LogInformation("User {UserId} already exists", request.Id);
return Result<UserResponse>.Conflict($"User {request.Id} already exists");
return Result<UserApplicationResponse>.Conflict($"User {request.Id} already exists");
}
var newUser = CreateUserCommand.ToEntity(request);
@@ -34,7 +34,7 @@ namespace Musify.Application.Users.Handlers
}
logger.LogInformation("Created user {UserId}", newUser.Id);
return Result.Created(UserResponse.FromEntity(newUser));
return Result.Created(UserApplicationResponse.FromEntity(newUser));
}
}
}