import { Injectable } from '@nestjs/common';
import { CreateSeasonTypeManager } from './managers/create-season-type.manager';
import { SeasonTypeDataService } from '../../data/services/season-type-data.service';
import { SeasonTypeEntity } from '../entities/season-type.entity';
import { DeleteSeasonTypeManager } from './managers/delete-season-type.manager';
import { UpdateSeasonTypeManager } from './managers/update-season-type.manager';
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
import { ActiveSeasonTypeManager } from './managers/active-season-type.manager';
import { InactiveSeasonTypeManager } from './managers/inactive-season-type.manager';
import { ConfirmSeasonTypeManager } from './managers/confirm-season-type.manager';
import { STATUS } from 'src/core/strings/constants/base.constants';
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
import { BatchConfirmSeasonTypeManager } from './managers/batch-confirm-season-type.manager';
import { BatchInactiveSeasonTypeManager } from './managers/batch-inactive-season-type.manager';
import { BatchActiveSeasonTypeManager } from './managers/batch-active-season-type.manager';
import { BatchDeleteSeasonTypeManager } from './managers/batch-delete-season-type.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { SeasonPeriodDataService } from 'src/modules/season-related/season-period/data/services/season-period-data.service';

@Injectable()
export class SeasonTypeDataOrchestrator extends BaseDataTransactionOrchestrator<SeasonTypeEntity> {
  constructor(
    private createManager: CreateSeasonTypeManager,
    private updateManager: UpdateSeasonTypeManager,
    private deleteManager: DeleteSeasonTypeManager,
    private activeManager: ActiveSeasonTypeManager,
    private confirmManager: ConfirmSeasonTypeManager,
    private inactiveManager: InactiveSeasonTypeManager,
    private batchDeleteManager: BatchDeleteSeasonTypeManager,
    private batchActiveManager: BatchActiveSeasonTypeManager,
    private batchConfirmManager: BatchConfirmSeasonTypeManager,
    private batchInactiveManager: BatchInactiveSeasonTypeManager,
    private serviceData: SeasonTypeDataService,
    private servicePeriodData: SeasonPeriodDataService,
  ) {
    super();
  }

  async create(data): Promise<SeasonTypeEntity> {
    this.createManager.setData(data);
    this.createManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
    await this.createManager.execute();
    return this.createManager.getResult();
  }

  async update(dataId, data): Promise<SeasonTypeEntity> {
    this.updateManager.setData(dataId, data);
    this.updateManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
    await this.updateManager.execute();
    return this.updateManager.getResult();
  }

  async delete(dataId): Promise<string> {
    this.deleteManager.setData(dataId);
    this.deleteManager.setService(
      this.serviceData,
      TABLE_NAME.SEASON_TYPE,
      this.servicePeriodData,
    );
    await this.deleteManager.execute();
    return this.deleteManager.getResult();
  }

  async batchDelete(dataIds: string[]): Promise<BatchResult> {
    this.batchDeleteManager.setData(dataIds);
    this.batchDeleteManager.setService(
      this.serviceData,
      TABLE_NAME.SEASON_TYPE,
      this.servicePeriodData,
    );
    await this.batchDeleteManager.execute();
    return this.batchDeleteManager.getResult();
  }

  async active(dataId): Promise<string> {
    this.activeManager.setData(dataId, STATUS.ACTIVE);
    this.activeManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
    await this.activeManager.execute();
    return this.activeManager.getResult();
  }

  async batchActive(dataIds: string[]): Promise<BatchResult> {
    this.batchActiveManager.setData(dataIds, STATUS.ACTIVE);
    this.batchActiveManager.setService(
      this.serviceData,
      TABLE_NAME.SEASON_TYPE,
    );
    await this.batchActiveManager.execute();
    return this.batchActiveManager.getResult();
  }

  async confirm(dataId): Promise<string> {
    this.confirmManager.setData(dataId, STATUS.ACTIVE);
    this.confirmManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
    await this.confirmManager.execute();
    return this.confirmManager.getResult();
  }

  async batchConfirm(dataIds: string[]): Promise<BatchResult> {
    this.batchConfirmManager.setData(dataIds, STATUS.ACTIVE);
    this.batchConfirmManager.setService(
      this.serviceData,
      TABLE_NAME.SEASON_TYPE,
    );
    await this.batchConfirmManager.execute();
    return this.batchConfirmManager.getResult();
  }

  async inactive(dataId): Promise<string> {
    this.inactiveManager.setData(dataId, STATUS.INACTIVE);
    this.inactiveManager.setService(
      this.serviceData,
      TABLE_NAME.SEASON_TYPE,
      this.servicePeriodData,
    );
    await this.inactiveManager.execute();
    return this.inactiveManager.getResult();
  }

  async batchInactive(dataIds: string[]): Promise<BatchResult> {
    this.batchInactiveManager.setData(dataIds, STATUS.INACTIVE);
    this.batchInactiveManager.setService(
      this.serviceData,
      TABLE_NAME.SEASON_TYPE,
      this.servicePeriodData,
    );
    await this.batchInactiveManager.execute();
    return this.batchInactiveManager.getResult();
  }
}
