Conditions | 3 |
Total Lines | 23 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {Inject} from '@nestjs/common'; |
||
19 | |||
20 | public async execute(command: RefuseHolidayCommand): Promise<string> { |
||
21 | const {moderator, id, moderationComment} = command; |
||
22 | |||
23 | const holiday = await this.holidayRepository.findOneById(id); |
||
24 | if (!holiday) { |
||
25 | throw new HolidayNotFoundException(); |
||
26 | } |
||
27 | |||
28 | if ( |
||
29 | false === this.canHolidayBeModerated.isSatisfiedBy(holiday, moderator) |
||
30 | ) { |
||
31 | throw new HolidayCantBeModeratedException(); |
||
32 | } |
||
33 | |||
34 | holiday.refuse( |
||
35 | moderator, |
||
36 | this.dateUtils.getCurrentDateToISOString(), |
||
37 | moderationComment |
||
38 | ); |
||
39 | await this.holidayRepository.save(holiday); |
||
40 | |||
41 | return holiday.getId(); |
||
42 | } |
||
44 |