| Total Complexity | 2 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { QueryHandler } from '@nestjs/cqrs'; |
||
| 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 | } |
||
| 31 |