Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 24 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { Inject } from '@nestjs/common'; |
||
2 | import { CommandHandler } from '@nestjs/cqrs'; |
||
3 | import { ShippingCostNotFoundException } from 'src/Domain/Order/Exception/ShippingCostNotFoundException'; |
||
4 | import { IShippingCostRepository } from 'src/Domain/Order/Repository/IShippingCostRepository'; |
||
5 | import { RemoveShippingCostCommand } from './RemoveShippingCostCommand'; |
||
6 | |||
7 | @CommandHandler(RemoveShippingCostCommand) |
||
8 | export class RemoveShippingCostCommandHandler { |
||
9 | constructor( |
||
10 | @Inject('IShippingCostRepository') |
||
11 | private readonly shippingCostRepository: IShippingCostRepository, |
||
12 | ) {} |
||
13 | |||
14 | public async execute({ id }: RemoveShippingCostCommand): Promise<void> { |
||
15 | const shippingcost = await this.shippingCostRepository.findOneById(id); |
||
16 | |||
17 | if (!shippingcost) { |
||
18 | throw new ShippingCostNotFoundException(); |
||
19 | } |
||
20 | |||
21 | await this.shippingCostRepository.remove(shippingcost); |
||
22 | } |
||
23 | } |
||
24 |