Conditions | 2 |
Total Lines | 21 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { |
||
29 | |||
30 | @Post(':id/discounts') |
||
31 | @Roles(UserRole.PHOTOGRAPHER) |
||
32 | @ApiOperation({ summary: 'Create a discount' }) |
||
33 | public async index( |
||
34 | @Param() idDto: IdDTO, |
||
35 | @Body() { amount, value, type }: DiscountDTO |
||
36 | ) { |
||
37 | try { |
||
38 | const id = await this.commandBus.execute( |
||
39 | new CreateDiscountCommand( |
||
40 | type, |
||
41 | amount, |
||
42 | value, |
||
43 | idDto.id |
||
44 | ) |
||
45 | ); |
||
46 | |||
47 | return { id }; |
||
48 | } catch (e) { |
||
49 | throw new BadRequestException(e.message); |
||
50 | } |
||
53 |