Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 31 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { QueryHandler } from '@nestjs/cqrs'; |
||
2 | import { Inject } from '@nestjs/common'; |
||
3 | import { GetShippingCostsQuery } from './GetShippingCostsQuery'; |
||
4 | import { IShippingCostRepository } from 'src/Domain/Order/Repository/IShippingCostRepository'; |
||
5 | import { ShippingCostView } from '../../View/ShippingCostView'; |
||
6 | |||
7 | @QueryHandler(GetShippingCostsQuery) |
||
8 | export class GetShippingCostsQueryHandler { |
||
9 | constructor( |
||
10 | @Inject('IShippingCostRepository') |
||
11 | private readonly shippingcostRepository: IShippingCostRepository |
||
12 | ) { } |
||
13 | |||
14 | public async execute(query: GetShippingCostsQuery): Promise<ShippingCostView[]> { |
||
15 | const shippingcostViews: ShippingCostView[] = []; |
||
16 | const shippingCosts = await this.shippingcostRepository.findShippingCosts(); |
||
17 | |||
18 | for (const shippingCost of shippingCosts) { |
||
19 | shippingcostViews.push( |
||
20 | new ShippingCostView( |
||
21 | shippingCost.getId(), |
||
22 | shippingCost.getGrams(), |
||
23 | shippingCost.getPriceFromCents(), |
||
24 | ) |
||
25 | ); |
||
26 | } |
||
27 | |||
28 | return shippingcostViews; |
||
29 | } |
||
30 | } |
||
31 |