Conditions | 3 |
Total Lines | 17 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {Inject} from '@nestjs/common'; |
||
19 | |||
20 | public async execute(command: RefuseHolidayCommand): Promise<string> { |
||
21 | const {user, id} = command; |
||
22 | |||
23 | const holiday = await this.holidayRepository.findOneById(id); |
||
24 | if (!holiday) { |
||
25 | throw new HolidayNotFoundException(); |
||
26 | } |
||
27 | |||
28 | if (false === this.canHolidayBeRefused.isSatisfiedBy(holiday, user)) { |
||
29 | throw new HolidayCantBeRefusedException(); |
||
30 | } |
||
31 | |||
32 | holiday.refuse(user, this.dateUtils.getCurrentDate().toISOString()); |
||
33 | await this.holidayRepository.save(holiday); |
||
34 | |||
35 | return holiday.getId(); |
||
36 | } |
||
38 |