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

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

public class DeleteDescriptionCommand : IRequest<Unit>
{
    public Guid TitleId { get; set; }
    public Guid LanguageId { get; set; }
    public string Value { get; set; } = default!;
    public bool IsOriginal { get; set; }

}

public class DeleteDescriptionCommandHandler(IAnimeTitleGateway titleGateway) : IRequestHandler<DeleteDescriptionCommand, Unit>
{
    public async Task<Unit> Handle(DeleteDescriptionCommand request, CancellationToken cancellationToken)
    {
        var title = await titleGateway.GetById(request.TitleId);
        var description = new Domain.Entities.MediaContent.CommonProperties.Description(request.LanguageId, request.IsOriginal, request.Value);
        title.CommonProperties.RemoveDescription(description);
        await titleGateway.Update(title);
        return Unit.Value;
    }
}