Conditions | 2 |
Total Lines | 30 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { |
||
28 | |||
29 | @Post() |
||
30 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
31 | @ApiOperation({title: 'Create new holiday'}) |
||
32 | public async index(@Body() dto: HolidayDTO, @LoggedUser() user: User) { |
||
33 | const { |
||
34 | leaveType, |
||
35 | startDate, |
||
36 | startsAllDay, |
||
37 | endDate, |
||
38 | endsAllDay, |
||
39 | comment |
||
40 | } = dto; |
||
41 | |||
42 | try { |
||
43 | const id = await this.commandBus.execute( |
||
44 | new CreateHolidayCommand( |
||
45 | user, |
||
46 | leaveType, |
||
47 | startDate, |
||
48 | Boolean(startsAllDay), |
||
49 | endDate, |
||
50 | Boolean(endsAllDay), |
||
51 | comment |
||
52 | ) |
||
53 | ); |
||
54 | |||
55 | return {id}; |
||
56 | } catch (e) { |
||
57 | throw new BadRequestException(e.message); |
||
58 | } |
||
61 |