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.
51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
using ErrorOr;
|
|
using Mediator;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
using Musify.Application.Contracts;
|
|
|
|
namespace Musify.Application.Albums
|
|
{
|
|
public record DeleteAlbumCommand(long UserId, Guid AlbumId)
|
|
: ICommand<ErrorOr<Success>>;
|
|
|
|
public class DeleteAlbumCommandHandler(
|
|
IDatabase database,
|
|
ILogger<DeleteAlbumCommandHandler> logger)
|
|
: ICommandHandler<DeleteAlbumCommand, ErrorOr<Success>>
|
|
{
|
|
public async ValueTask<ErrorOr<Success>> Handle(DeleteAlbumCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var album = await database.UserAlbums
|
|
.SingleOrDefaultAsync(a => a.Id == request.AlbumId, cancellationToken);
|
|
if (album is null)
|
|
{
|
|
logger.LogDebug("Album {AlbumId} not found", request.AlbumId);
|
|
return Error.NotFound();
|
|
}
|
|
|
|
if (album.OwnerUserId != request.UserId)
|
|
{
|
|
logger.LogWarning("Album {AlbumId} does not belong to user {UserId}", request.AlbumId, request.UserId);
|
|
return Error.Unauthorized();
|
|
}
|
|
|
|
database.UserAlbums.Remove(album);
|
|
|
|
try
|
|
{
|
|
await database.SaveChangesAsync(cancellationToken);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
logger.LogError(exception, "Failed to delete album {AlbumId}", request.AlbumId);
|
|
return Error.Failure(description: $"Failed to delete album {request.AlbumId}");
|
|
}
|
|
|
|
logger.LogInformation("Deleted album {AlbumId} for user {UserId}", request.AlbumId, request.UserId);
|
|
|
|
return new Success();
|
|
}
|
|
}
|
|
}
|