Moves the six backend projects on disk into Core/ and Hosts/ subfolders, matching the solution folders already defined in Musify.slnx, so the file explorer reflects the same layout as the solution: backend/Core/Musify.Domain backend/Core/Musify.Application backend/Core/Musify.Infrastructure backend/Hosts/Musify.Api backend/Hosts/Musify.Worker backend/Hosts/Musify.StreamingGateway Updates every reference to the old paths: ProjectReference entries in Musify.Api.csproj and Musify.Worker.csproj, the three Dockerfiles, deploy/scripts/migrate.ps1|sh, deploy/zitadel/provision.ps1, deploy/up.ps1, deploy/README.md and docs/development.md. Also fixes a stale Dockerfile comment pointing at a compose file that no longer exists. Verified with `dotnet build Musify.slnx` against the new layout.
58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using ErrorOr;
|
|
using Mediator;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
using Musify.Application.Contracts;
|
|
using Musify.Domain.Entities;
|
|
|
|
namespace Musify.Application.Users
|
|
{
|
|
public record SyncUserCommand(
|
|
long Id,
|
|
string Name,
|
|
string? FirstName,
|
|
string? SecondName,
|
|
string? ProfilePictureUrl)
|
|
: ICommand<ErrorOr<Success>>;
|
|
|
|
public class SyncUserCommandHandler(IDatabase database, ILogger<SyncUserCommandHandler> logger)
|
|
: ICommandHandler<SyncUserCommand, ErrorOr<Success>>
|
|
{
|
|
public async ValueTask<ErrorOr<Success>> Handle(SyncUserCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var user = await database.Users
|
|
.SingleOrDefaultAsync(u => u.Id == request.Id, cancellationToken);
|
|
|
|
if (user is null)
|
|
{
|
|
await database.Users.AddAsync(new User
|
|
{
|
|
Id = request.Id,
|
|
Name = request.Name,
|
|
NormalizedName = request.Name.ToUpperInvariant(),
|
|
FirstName = request.FirstName,
|
|
SecondName = request.SecondName,
|
|
ProfilePictureUrl = request.ProfilePictureUrl
|
|
}, cancellationToken);
|
|
|
|
await database.SaveChangesAsync(cancellationToken);
|
|
logger.LogInformation("Provisioned user {UserId}", request.Id);
|
|
|
|
return new Success();
|
|
}
|
|
|
|
user.Name = request.Name;
|
|
user.NormalizedName = request.Name.ToUpperInvariant();
|
|
user.FirstName = request.FirstName;
|
|
user.SecondName = request.SecondName;
|
|
user.ProfilePictureUrl = request.ProfilePictureUrl;
|
|
|
|
var written = await database.SaveChangesAsync(cancellationToken);
|
|
if (written > 0)
|
|
logger.LogInformation("Synced profile for user {UserId}", request.Id);
|
|
|
|
return new Success();
|
|
}
|
|
}
|
|
}
|