refactor(application): co-locate each command/query with its handler
One file per use case under the feature folder (Tracks/PlayLists/Users), dropping the Commands/Queries/Handlers sub-folders and their namespaces. Each file now holds the record and its handler in namespace Musify.Application.<Feature>; external usings updated accordingly. Build: 0 warnings, 0 errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+4
-2
@@ -3,11 +3,13 @@ using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.PlayLists.Commands;
|
||||
using Musify.Domain.Entities;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record AddTrackToPlayListCommand(long UserId, Guid PlayListId, Guid TrackId)
|
||||
: ICommand<ErrorOr<Success>>;
|
||||
|
||||
public class AddTrackToPlayListCommandHandler(
|
||||
IDatabase database,
|
||||
ILogger<AddTrackToPlayListCommandHandler> logger)
|
||||
@@ -1,8 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
|
||||
namespace Musify.Application.PlayLists.Commands
|
||||
{
|
||||
public record AddTrackToPlayListCommand(long UserId, Guid PlayListId, Guid TrackId)
|
||||
: ICommand<ErrorOr<Success>>;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
|
||||
namespace Musify.Application.PlayLists.Commands
|
||||
{
|
||||
public record CreatePlayListCommand(
|
||||
long UserId,
|
||||
string Name,
|
||||
string Description,
|
||||
Guid? PictureIntentId)
|
||||
: ICommand<ErrorOr<PlayListApplicationResponse>>;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
|
||||
namespace Musify.Application.PlayLists.Commands
|
||||
{
|
||||
public record DeletePlayListCommand(long UserId, Guid PlayListId)
|
||||
: ICommand<ErrorOr<Success>>;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
|
||||
namespace Musify.Application.PlayLists.Commands
|
||||
{
|
||||
public record RemoveTrackFromPlayListCommand(long UserId, Guid PlayListId, Guid TrackId)
|
||||
: ICommand<ErrorOr<Success>>;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
|
||||
namespace Musify.Application.PlayLists.Commands
|
||||
{
|
||||
public record RequestPlayListPictureUploadCommand(
|
||||
long UserId,
|
||||
string FileType,
|
||||
string ContentType,
|
||||
long? ExpectedSizeBytes = null)
|
||||
: ICommand<ErrorOr<PlayListPictureUploadResponse>>;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
|
||||
namespace Musify.Application.PlayLists.Commands
|
||||
{
|
||||
public record UpdatePlayListCommand(
|
||||
long UserId,
|
||||
Guid PlayListId,
|
||||
string? NewName,
|
||||
string? NewDescription,
|
||||
Guid? NewPictureIntentId)
|
||||
: ICommand<ErrorOr<PlayListApplicationResponse>>;
|
||||
}
|
||||
+8
-2
@@ -5,14 +5,20 @@ using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Configuration;
|
||||
using Musify.Application.Shared;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Application.PlayLists.Commands;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
using Musify.Application.Services;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record CreatePlayListCommand(
|
||||
long UserId,
|
||||
string Name,
|
||||
string Description,
|
||||
Guid? PictureIntentId)
|
||||
: ICommand<ErrorOr<PlayListApplicationResponse>>;
|
||||
|
||||
public class CreatePlayListCommandHandler(
|
||||
IEventBus eventBus,
|
||||
IDatabase database,
|
||||
+5
-3
@@ -4,11 +4,13 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Application.PlayLists.Commands;
|
||||
using Musify.Domain.ValueObjects;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record DeletePlayListCommand(long UserId, Guid PlayListId)
|
||||
: ICommand<ErrorOr<Success>>;
|
||||
|
||||
public class DeletePlayListCommandHandler(
|
||||
IDatabase database,
|
||||
IEventBus eventBus,
|
||||
@@ -57,4 +59,4 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
return new Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -1,12 +1,14 @@
|
||||
using ErrorOr;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
using Musify.Application.PlayLists.Queries;
|
||||
using Mediator;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record GetPlayListByIdQuery(Guid Id)
|
||||
: IQuery<ErrorOr<PlayListApplicationResponse>>;
|
||||
|
||||
public class GetPlayListByIdQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetPlayListByIdQuery, ErrorOr<PlayListApplicationResponse>>
|
||||
{
|
||||
@@ -24,4 +26,4 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
return playList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-2
@@ -3,12 +3,17 @@ using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.PlayLists.Queries;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
using X.PagedList.EF;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record GetPlayListTracksQuery(
|
||||
Guid PlayListId,
|
||||
int PageNumber = 1,
|
||||
int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<TrackApplicationResponse>>>;
|
||||
|
||||
public class GetPlayListTracksQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetPlayListTracksQuery, ErrorOr<PaginatedResponse<TrackApplicationResponse>> >
|
||||
{
|
||||
+5
-3
@@ -2,13 +2,15 @@ using ErrorOr;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
using Musify.Application.PlayLists.Queries;
|
||||
using X.PagedList.EF;
|
||||
using Mediator;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record GetPlayListsQuery(int PageNumber = 1, int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<PlayListApplicationResponse>> >;
|
||||
|
||||
public class GetPlayListsQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetPlayListsQuery, ErrorOr<PaginatedResponse<PlayListApplicationResponse> >>
|
||||
{
|
||||
@@ -25,4 +27,4 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
return PaginatedResponse<PlayListApplicationResponse>.FromPagedList(pagedPlayLists);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -2,13 +2,19 @@ using ErrorOr;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
using Musify.Application.PlayLists.Queries;
|
||||
using X.PagedList.EF;
|
||||
using Mediator;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record GetPlayListsByUserIdQuery(
|
||||
long UserId,
|
||||
string? Name,
|
||||
int PageNumber = 1,
|
||||
int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<PlayListApplicationResponse>> >;
|
||||
|
||||
public class GetPlayListsByUserIdQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetPlayListsByUserIdQuery, ErrorOr<PaginatedResponse<PlayListApplicationResponse> > >
|
||||
{
|
||||
@@ -34,4 +40,4 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
return PaginatedResponse<PlayListApplicationResponse>.FromPagedList(pagedPlayLists);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
|
||||
namespace Musify.Application.PlayLists.Queries
|
||||
{
|
||||
public record GetPlayListByIdQuery(Guid Id)
|
||||
: IQuery<ErrorOr<PlayListApplicationResponse>>;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
|
||||
namespace Musify.Application.PlayLists.Queries
|
||||
{
|
||||
public record GetPlayListTracksQuery(
|
||||
Guid PlayListId,
|
||||
int PageNumber = 1,
|
||||
int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<TrackApplicationResponse>>>;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
|
||||
namespace Musify.Application.PlayLists.Queries
|
||||
{
|
||||
public record GetPlayListsByUserIdQuery(
|
||||
long UserId,
|
||||
string? Name,
|
||||
int PageNumber = 1,
|
||||
int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<PlayListApplicationResponse>> >;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
|
||||
namespace Musify.Application.PlayLists.Queries
|
||||
{
|
||||
public record GetPlayListsQuery(int PageNumber = 1, int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<PlayListApplicationResponse>> >;
|
||||
}
|
||||
+4
-2
@@ -3,10 +3,12 @@ using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.PlayLists.Commands;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record RemoveTrackFromPlayListCommand(long UserId, Guid PlayListId, Guid TrackId)
|
||||
: ICommand<ErrorOr<Success>>;
|
||||
|
||||
public class RemoveTrackFromPlayListCommandHandler(
|
||||
IDatabase database,
|
||||
ILogger<RemoveTrackFromPlayListCommandHandler> logger)
|
||||
+8
-2
@@ -3,15 +3,21 @@ using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Configuration;
|
||||
using Musify.Application.PlayLists.Commands;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
using Musify.Application.Services;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Domain.ValueObjects;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record RequestPlayListPictureUploadCommand(
|
||||
long UserId,
|
||||
string FileType,
|
||||
string ContentType,
|
||||
long? ExpectedSizeBytes = null)
|
||||
: ICommand<ErrorOr<PlayListPictureUploadResponse>>;
|
||||
|
||||
public class RequestPlayListPictureUploadCommandHandler(
|
||||
IDatabase database,
|
||||
UploadIntentValidator uploadIntentValidator,
|
||||
+9
-2
@@ -5,14 +5,21 @@ using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Configuration;
|
||||
using Musify.Application.Shared;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Application.PlayLists.Commands;
|
||||
using Musify.Application.PlayLists.Responses;
|
||||
using Musify.Application.Services;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.PlayLists.Handlers
|
||||
namespace Musify.Application.PlayLists
|
||||
{
|
||||
public record UpdatePlayListCommand(
|
||||
long UserId,
|
||||
Guid PlayListId,
|
||||
string? NewName,
|
||||
string? NewDescription,
|
||||
Guid? NewPictureIntentId)
|
||||
: ICommand<ErrorOr<PlayListApplicationResponse>>;
|
||||
|
||||
public class UpdatePlayListCommandHandler(
|
||||
IEventBus eventBus,
|
||||
IDatabase database,
|
||||
Reference in New Issue
Block a user