using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Requests.ExportOptions;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.ExcelServices;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;

public abstract class ProcessMapPlanExportService<TDto> : ExportExcelService<TDto, WellRelatedExportRequest>
    where TDto : ProcessMapPlanBaseDto
{
    protected readonly IWellService wellService;

    private readonly IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepository;

    protected ProcessMapPlanExportService(IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> processMapPlanRepository,
        IWellService wellService)
    {
        this.processMapPlanRepository = processMapPlanRepository;
        this.wellService = wellService;
    }

    protected override async Task<IEnumerable<TDto>> GetDtosAsync(WellRelatedExportRequest options, CancellationToken token)
    {
        var request = new ProcessMapPlanBaseRequestWithWell(options.IdWell);

        var dtos = await processMapPlanRepository.GetCurrent(request, token);
        return dtos;
    }
}