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

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

public class DeleteAnimeTitleCommand : IRequest<Unit>
{
    public Guid TitleId { get; set; }
}

public class DeleteAnimtTitleCommandHandler(IAnimeTitleGateway titleGateway, ILanguageGateway languageGateway) : IRequestHandler<DeleteAnimeTitleCommand, Unit>
{
    public async Task<Unit> Handle(DeleteAnimeTitleCommand request, CancellationToken cancellationToken)
    {
        var title = await titleGateway.GetById(request.TitleId);
        title.Delete();
        await titleGateway.Update(title);
        return Unit.Value;
    }
}