import { Inject } from '@nestjs/common' ; import { IEventRepository } from '../Repository/IEventRepository' ; import { User } from 'src/Domain/HumanResource/User/User.entity' ; import { ILeaveRepository } from 'src/Domain/HumanResource/Leave/Repository/ILeaveRepository' ; export class DoesEventsOrLeaveExistForPeriod { constructor ( @ Inject ( 'IEventRepository' ) private readonly eventRepository , @ Inject ( 'ILeaveRepository' ) private readonly leaveRepository ) { } public async isSatisfiedBy ( user , startDate , endDate ) { const [ events , leaves ] = await Promise . all ( [ this . eventRepository . countEventsByUserAndPeriod ( user , startDate , endDate ) , this . leaveRepository . countLeavesByUserAndPeriod ( user , startDate , endDate ) ] ) ; return events + leaves > 0 ; } }