| Total Complexity | 2 | 
| Total Lines | 20 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import { Inject } from '@nestjs/common'; | ||
| 6 | |||
| 7 | @CommandHandler(UpdateShootingCommand) | ||
| 8 | export class UpdateShootingCommandHandler { | ||
| 9 | constructor( | ||
| 10 |     @Inject('IShootingRepository') | ||
| 11 | private readonly shootingRepository: IShootingRepository, | ||
| 12 |   ) { } | ||
| 13 | |||
| 14 |   public async execute(command: UpdateShootingCommand): Promise<string> { | ||
| 15 |     const { name, closingDate, shootingDate, id } = command; | ||
| 16 | |||
| 17 | const shooting = await this.shootingRepository.findOneById(id); | ||
| 18 |     if (!shooting) { | ||
| 19 | throw new ShootingNotFoundException(); | ||
| 20 | } | ||
| 21 | |||
| 22 | shooting.update(name, shootingDate, closingDate); | ||
| 23 | await this.shootingRepository.save(shooting); | ||
| 24 | |||
| 25 | return shooting.getId(); | ||
| 26 | } | ||
| 28 |