Passed
Pull Request — master (#113)
by Mathieu
11:33
created

DoesEventsExistForPeriod.isSatisfiedBy   A

Complexity

Conditions 1

Size

Total Lines 12
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 12
c 0
b 0
f 0
rs 9.85
cc 1
1
import {Inject} from '@nestjs/common';
2
import {IEventRepository} from '../Repository/IEventRepository';
3
import {User} from 'src/Domain/HumanResource/User/User.entity';
4
5
export class DoesEventsExistForPeriod {
6
  constructor(
7
    @Inject('IEventRepository')
8
    private readonly eventRepository: IEventRepository
9
  ) {}
10
11
  public async isSatisfiedBy(
12
    user: User,
13
    startDate: string,
14
    endDate: string
15
  ): Promise<boolean> {
16
    return (
17
      (await this.eventRepository.countExistingEventsByUserAndPeriod(
18
        user,
19
        startDate,
20
        endDate
21
      )) > 0
22
    );
23
  }
24
}
25