using MediatR;
using SolutionErp.Application.Master.Suppliers.Dtos;
using SolutionErp.Application.Master.Suppliers.Import;

namespace SolutionErp.Application.Master.Suppliers.Commands.ImportSuppliers;

/// <summary>
/// Preview import NCC từ file Excel (KHÔNG ghi DB). Stream do controller mở từ IFormFile
/// (mirror UploadPurchaseEvaluationAttachmentCommand — command mang Stream).
/// </summary>
public sealed record SupplierImportPreviewCommand(Stream Xlsx) : IRequest<SupplierImportPreviewDto>;

public sealed class SupplierImportPreviewCommandHandler(ISupplierExcelImportService importService)
    : IRequestHandler<SupplierImportPreviewCommand, SupplierImportPreviewDto>
{
    public Task<SupplierImportPreviewDto> Handle(SupplierImportPreviewCommand request, CancellationToken ct)
        => importService.PreviewAsync(request.Xlsx, ct);
}
