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

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

public class SetReleaseDateCommand : IRequest<Unit>
{
    public Guid TitleId { get; set; }
    public DateTimeOffset? Value { get; set; }

}

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