23 lines
720 B
C#
23 lines
720 B
C#
using MediatR;
|
|
using Modules.Library.Application.Gateways;
|
|
|
|
namespace Modules.Library.Application.Commands.Anime.Title.Properties;
|
|
|
|
public class SetCompletedCommand : IRequest<Unit>
|
|
{
|
|
public Guid TitleId { get; set; }
|
|
public bool Value { get; set; }
|
|
|
|
}
|
|
|
|
public class SetCompletedCommandHandler(IAnimeTitleGateway titleGateway) : IRequestHandler<SetCompletedCommand, Unit>
|
|
{
|
|
public async Task<Unit> Handle(SetCompletedCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var title = await titleGateway.GetById(request.TitleId);
|
|
if (request.Value) title.SetCompleted();
|
|
else title.SetNotCompleted();
|
|
await titleGateway.Update(title);
|
|
return Unit.Value;
|
|
}
|
|
} |