using MediatR;
using SolutionErp.Application.Forms.Services;
using SolutionErp.Application.Reports.Services;
using SolutionErp.Domain.Contracts;

namespace SolutionErp.Application.Reports.Commands.ExportContractsToExcel;

public record ExportContractsToExcelCommand(
    ContractPhase? Phase = null,
    Guid? SupplierId = null,
    Guid? ProjectId = null,
    DateTime? FromDate = null,
    DateTime? ToDate = null) : IRequest<RenderResult>;

public class ExportContractsToExcelCommandHandler(IContractExcelExporter exporter)
    : IRequestHandler<ExportContractsToExcelCommand, RenderResult>
{
    public Task<RenderResult> Handle(ExportContractsToExcelCommand request, CancellationToken ct)
        => exporter.ExportAsync(request.Phase, request.SupplierId, request.ProjectId, request.FromDate, request.ToDate, ct);
}
