using MediatR;
using Modules.Library.Application.Gateways;

namespace Modules.Library.Application.Commands.Anime.Title.Properties;

public class SetDirectorCommand : IRequest<Unit>
{
    public Guid TitleId { get; init; }
    public string? Value { get; init; }

}

public class SetDirectorCommandHandler(IAnimeTitleGateway titleGateway) : IRequestHandler<SetDirectorCommand, Unit>
{
    public async Task<Unit> Handle(SetDirectorCommand request, CancellationToken cancellationToken)
    {
        var title = await titleGateway.GetById(request.TitleId, cancellationToken);
        title.SetDirector(request.Value);
        await titleGateway.Update(title, cancellationToken);
        return Unit.Value;
    }
}