23 lines
747 B
C#
23 lines
747 B
C#
using MediatR;
|
|
using Modules.Library.Application.Gateways;
|
|
|
|
namespace Modules.Library.Application.Commands.Anime.Title.Properties.Genre;
|
|
|
|
public class DeleteGenreCommand : IRequest<Unit>
|
|
{
|
|
public Guid TitleId { get; set; }
|
|
public Guid GenreId { get; set; }
|
|
|
|
}
|
|
|
|
public class DeleteGenreCommandHandler(IAnimeTitleGateway titleGateway) : IRequestHandler<DeleteGenreCommand, Unit>
|
|
{
|
|
public async Task<Unit> Handle(DeleteGenreCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var title = await titleGateway.GetById(request.TitleId);
|
|
var commonProperties = title.CommonProperties;
|
|
commonProperties.RemoveGenre(request.GenreId);
|
|
await titleGateway.Update(title);
|
|
return Unit.Value;
|
|
}
|
|
} |