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.
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,
|
||||
@@ -1,13 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
|
||||
namespace Musify.Application.Tracks.Commands
|
||||
{
|
||||
public record CreateTrackCommand(
|
||||
long UserId,
|
||||
string Title,
|
||||
Guid PictureIntentId,
|
||||
Guid AudioIntentId)
|
||||
: ICommand<ErrorOr<TrackApplicationResponse>>;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
|
||||
namespace Musify.Application.Tracks.Commands
|
||||
{
|
||||
public record DeleteTrackCommand(
|
||||
long UserId,
|
||||
Guid TrackId)
|
||||
: ICommand<ErrorOr<Success>>;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
|
||||
namespace Musify.Application.Tracks.Commands
|
||||
{
|
||||
public record RequestTrackUploadUrlsCommand(
|
||||
long UserId,
|
||||
string PictureFileType,
|
||||
string PictureContentType,
|
||||
string AudioFileType,
|
||||
string AudioContentType,
|
||||
long? ExpectedPictureSizeBytes = null,
|
||||
long? ExpectedAudioSizeBytes = null)
|
||||
: ICommand<ErrorOr<TrackUploadUrlsResponse>>;
|
||||
}
|
||||
+8
-2
@@ -5,15 +5,21 @@ using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Configuration;
|
||||
using Musify.Application.Shared;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Application.Tracks.Commands;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
using Musify.Application.Services;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Domain.ValueObjects;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.Tracks.Handlers
|
||||
namespace Musify.Application.Tracks
|
||||
{
|
||||
public record CreateTrackCommand(
|
||||
long UserId,
|
||||
string Title,
|
||||
Guid PictureIntentId,
|
||||
Guid AudioIntentId)
|
||||
: ICommand<ErrorOr<TrackApplicationResponse>>;
|
||||
|
||||
public class CreateTrackCommandHandler(
|
||||
IDatabase database,
|
||||
IEventBus eventBus,
|
||||
+7
-3
@@ -2,13 +2,17 @@ using ErrorOr;
|
||||
using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Tracks.Commands;
|
||||
using Musify.Domain.ValueObjects;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.Tracks.Handlers
|
||||
namespace Musify.Application.Tracks
|
||||
{
|
||||
public record DeleteTrackCommand(
|
||||
long UserId,
|
||||
Guid TrackId)
|
||||
: ICommand<ErrorOr<Success>>;
|
||||
|
||||
public class DeleteTrackCommandHandler(
|
||||
IDatabase database,
|
||||
IEventBus eventBus,
|
||||
@@ -67,4 +71,4 @@ namespace Musify.Application.Tracks.Handlers
|
||||
return new Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -2,11 +2,13 @@ using ErrorOr;
|
||||
using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Tracks.Queries;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
|
||||
namespace Musify.Application.Tracks.Handlers
|
||||
namespace Musify.Application.Tracks
|
||||
{
|
||||
public record GetTrackByIdQuery(Guid TrackId)
|
||||
: IQuery<ErrorOr<TrackApplicationResponse>>;
|
||||
|
||||
public class GetTrackByIdQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetTrackByIdQuery, ErrorOr<TrackApplicationResponse> >
|
||||
{
|
||||
@@ -23,4 +25,4 @@ namespace Musify.Application.Tracks.Handlers
|
||||
return track;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -4,12 +4,14 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Configuration;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Tracks.Queries;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
using Musify.Domain.ValueObjects;
|
||||
|
||||
namespace Musify.Application.Tracks.Handlers
|
||||
namespace Musify.Application.Tracks
|
||||
{
|
||||
public record GetTrackStreamQuery(Guid TrackId, long UserId)
|
||||
: IQuery<ErrorOr<TrackStreamResponse>>;
|
||||
|
||||
public class GetTrackStreamQueryHandler(
|
||||
IDatabase database,
|
||||
IStreamTicketService ticketService,
|
||||
+5
-3
@@ -2,13 +2,15 @@ using ErrorOr;
|
||||
using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.Tracks.Queries;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
using X.PagedList.EF;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.Tracks.Handlers
|
||||
namespace Musify.Application.Tracks
|
||||
{
|
||||
public record GetTracksQuery(int PageNumber = 1, int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<TrackApplicationResponse> >>;
|
||||
|
||||
public class GetTracksQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetTracksQuery, ErrorOr<PaginatedResponse<TrackApplicationResponse>> >
|
||||
{
|
||||
@@ -26,4 +28,4 @@ namespace Musify.Application.Tracks.Handlers
|
||||
return PaginatedResponse<TrackApplicationResponse>.FromPagedList(pagedTracks);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -2,13 +2,19 @@ using ErrorOr;
|
||||
using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.Tracks.Queries;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
using X.PagedList.EF;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.Tracks.Handlers
|
||||
namespace Musify.Application.Tracks
|
||||
{
|
||||
public record GetTracksByUserIdQuery(
|
||||
long UserId,
|
||||
string? Name = null,
|
||||
int PageNumber = 1,
|
||||
int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<TrackApplicationResponse> > >;
|
||||
|
||||
public class GetTracksByUserIdQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetTracksByUserIdQuery, ErrorOr<PaginatedResponse<TrackApplicationResponse>> >
|
||||
{
|
||||
@@ -38,4 +44,4 @@ namespace Musify.Application.Tracks.Handlers
|
||||
return PaginatedResponse<TrackApplicationResponse>.FromPagedList(pagedTracks);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
|
||||
namespace Musify.Application.Tracks.Queries
|
||||
{
|
||||
public record GetTrackByIdQuery(Guid TrackId)
|
||||
: IQuery<ErrorOr<TrackApplicationResponse>>;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
|
||||
namespace Musify.Application.Tracks.Queries
|
||||
{
|
||||
public record GetTrackStreamQuery(Guid TrackId, long UserId)
|
||||
: IQuery<ErrorOr<TrackStreamResponse>>;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
|
||||
namespace Musify.Application.Tracks.Queries
|
||||
{
|
||||
public record GetTracksByUserIdQuery(
|
||||
long UserId,
|
||||
string? Name = null,
|
||||
int PageNumber = 1,
|
||||
int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<TrackApplicationResponse> > >;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
|
||||
namespace Musify.Application.Tracks.Queries
|
||||
{
|
||||
public record GetTracksQuery(int PageNumber = 1, int PageSize = 10)
|
||||
: IQuery<ErrorOr<PaginatedResponse<TrackApplicationResponse> >>;
|
||||
}
|
||||
+11
-2
@@ -4,14 +4,23 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Configuration;
|
||||
using Musify.Application.Services;
|
||||
using Musify.Application.Tracks.Commands;
|
||||
using Musify.Application.Tracks.Responses;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Domain.ValueObjects;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.Tracks.Handlers
|
||||
namespace Musify.Application.Tracks
|
||||
{
|
||||
public record RequestTrackUploadUrlsCommand(
|
||||
long UserId,
|
||||
string PictureFileType,
|
||||
string PictureContentType,
|
||||
string AudioFileType,
|
||||
string AudioContentType,
|
||||
long? ExpectedPictureSizeBytes = null,
|
||||
long? ExpectedAudioSizeBytes = null)
|
||||
: ICommand<ErrorOr<TrackUploadUrlsResponse>>;
|
||||
|
||||
public class RequestTrackUploadUrlsCommandHandler(
|
||||
IDatabase database,
|
||||
UploadIntentValidator uploadIntentValidator,
|
||||
@@ -1,26 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Users.Responses;
|
||||
using Musify.Domain.Entities;
|
||||
|
||||
namespace Musify.Application.Users.Commands
|
||||
{
|
||||
public record CreateUserCommand(long Id,
|
||||
string Name,
|
||||
string? FirstName,
|
||||
string? SecondName)
|
||||
: ICommand<ErrorOr<UserApplicationResponse>>
|
||||
{
|
||||
public static User ToEntity(CreateUserCommand command)
|
||||
{
|
||||
return new User
|
||||
{
|
||||
Id = command.Id,
|
||||
Name = command.Name,
|
||||
NormalizedName = command.Name.ToUpperInvariant(),
|
||||
FirstName = command.FirstName,
|
||||
SecondName = command.SecondName
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
|
||||
namespace Musify.Application.Users.Commands
|
||||
{
|
||||
public record SyncUserCommand(
|
||||
long Id,
|
||||
string Name,
|
||||
string? FirstName,
|
||||
string? SecondName,
|
||||
string? ProfilePictureUrl)
|
||||
: ICommand<ErrorOr<Success>>;
|
||||
}
|
||||
+22
-3
@@ -3,11 +3,30 @@ using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Users.Commands;
|
||||
using Musify.Application.Users.Responses;
|
||||
using Musify.Domain.Entities;
|
||||
|
||||
namespace Musify.Application.Users.Handlers
|
||||
namespace Musify.Application.Users
|
||||
{
|
||||
public record CreateUserCommand(long Id,
|
||||
string Name,
|
||||
string? FirstName,
|
||||
string? SecondName)
|
||||
: ICommand<ErrorOr<UserApplicationResponse>>
|
||||
{
|
||||
public static User ToEntity(CreateUserCommand command)
|
||||
{
|
||||
return new User
|
||||
{
|
||||
Id = command.Id,
|
||||
Name = command.Name,
|
||||
NormalizedName = command.Name.ToUpperInvariant(),
|
||||
FirstName = command.FirstName,
|
||||
SecondName = command.SecondName
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class CreateUserCommandHandler(IDatabase database, ILogger<CreateUserCommandHandler> logger)
|
||||
: ICommandHandler<CreateUserCommand, ErrorOr<UserApplicationResponse> >
|
||||
{
|
||||
@@ -37,4 +56,4 @@ namespace Musify.Application.Users.Handlers
|
||||
return UserApplicationResponse.FromEntity(newUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -2,11 +2,13 @@ using ErrorOr;
|
||||
using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Users.Queries;
|
||||
using Musify.Application.Users.Responses;
|
||||
|
||||
namespace Musify.Application.Users.Handlers
|
||||
namespace Musify.Application.Users
|
||||
{
|
||||
public record GetUserByIdQuery(long Id)
|
||||
: IQuery<ErrorOr<UserApplicationResponse> >;
|
||||
|
||||
public class GetUserByIdQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetUserByIdQuery, ErrorOr<UserApplicationResponse> >
|
||||
{
|
||||
@@ -24,4 +26,4 @@ namespace Musify.Application.Users.Handlers
|
||||
return user;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -2,13 +2,15 @@ using ErrorOr;
|
||||
using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.Users.Queries;
|
||||
using Musify.Application.Users.Responses;
|
||||
using X.PagedList.EF;
|
||||
using Musify.Application.Contracts;
|
||||
|
||||
namespace Musify.Application.Users.Handlers
|
||||
namespace Musify.Application.Users
|
||||
{
|
||||
public record GetUsersQuery(int PageNumber, int PageSize, string? UsernameSearch = null)
|
||||
: IQuery<ErrorOr<PaginatedResponse<UserApplicationResponse> >>;
|
||||
|
||||
public class GetUsersQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetUsersQuery, ErrorOr<PaginatedResponse<UserApplicationResponse> > >
|
||||
{
|
||||
@@ -32,4 +34,4 @@ namespace Musify.Application.Users.Handlers
|
||||
return PaginatedResponse<UserApplicationResponse>.FromPagedList(pagedUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Users.Responses;
|
||||
|
||||
namespace Musify.Application.Users.Queries
|
||||
{
|
||||
public record GetUserByIdQuery(long Id)
|
||||
: IQuery<ErrorOr<UserApplicationResponse> >;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Musify.Application.Pagination;
|
||||
using Musify.Application.Users.Responses;
|
||||
|
||||
namespace Musify.Application.Users.Queries
|
||||
{
|
||||
public record GetUsersQuery(int PageNumber, int PageSize, string? UsernameSearch = null)
|
||||
: IQuery<ErrorOr<PaginatedResponse<UserApplicationResponse> >>;
|
||||
}
|
||||
+9
-2
@@ -3,11 +3,18 @@ using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Users.Commands;
|
||||
using Musify.Domain.Entities;
|
||||
|
||||
namespace Musify.Application.Users.Handlers
|
||||
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>>
|
||||
{
|
||||
Reference in New Issue
Block a user