Total Complexity | 2 |
Total Lines | 16 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { Inject } from '@nestjs/common'; |
||
6 | |||
7 | @CommandHandler(RemoveDiscountCommand) |
||
8 | export class RemoveDiscountCommandHandler { |
||
9 | constructor( |
||
10 | @Inject('IDiscountRepository') |
||
11 | private readonly discountRepository: IDiscountRepository, |
||
12 | ) {} |
||
13 | |||
14 | public async execute({ id }: RemoveDiscountCommand): Promise<void> { |
||
15 | const discount = await this.discountRepository.findOneById(id); |
||
16 | |||
17 | if (!discount) { |
||
18 | throw new DiscountNotFoundException(); |
||
19 | } |
||
20 | |||
21 | await this.discountRepository.remove(discount); |
||
22 | } |
||
24 |