24 lines
845 B
C#
24 lines
845 B
C#
using MediatR;
|
|
using Modules.Library.Application.Gateways;
|
|
using Modules.Rating.Api.Commands;
|
|
|
|
namespace Modules.Library.Application.Commands.Anime.Title;
|
|
|
|
public class UnrateTitleCommand : IRequest<Unit>
|
|
{
|
|
public Guid TitleId { get; set; }
|
|
}
|
|
|
|
public class UnrateTitleCommandHandler(IAnimeTitleGateway titleGateway, IMediator mediator) : IRequestHandler<UnrateTitleCommand, Unit>
|
|
{
|
|
public async Task<Unit> Handle(UnrateTitleCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var subjectId = new Guid("8393230f-78e3-473b-a5dc-3221917e0aeb"); //user
|
|
var title = await titleGateway.GetById(request.TitleId);
|
|
if (title != null && !title.Deleted)
|
|
{
|
|
await mediator.Send(new UnrateObjectCommand { ObjectId = title.Id, SubjectId = subjectId });
|
|
}
|
|
return Unit.Value;
|
|
}
|
|
} |