| Total Complexity | 2 | 
| Total Lines | 36 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import { Inject } from '@nestjs/common'; | 
            ||
| 6 | |||
| 7 | @CommandHandler(UpdateLeaveRequestCommand)  | 
            ||
| 8 | export class UpdateLeaveRequestCommandHandler { | 
            ||
| 9 | constructor(  | 
            ||
| 10 |     @Inject('ILeaveRequestRepository') | 
            ||
| 11 | private readonly leaveRequestRepository: ILeaveRequestRepository  | 
            ||
| 12 |   ) { } | 
            ||
| 13 | |||
| 14 |   public async execute(command: UpdateLeaveRequestCommand): Promise<string> { | 
            ||
| 15 |     const { | 
            ||
| 16 | endDate,  | 
            ||
| 17 | endsAllDay,  | 
            ||
| 18 | id,  | 
            ||
| 19 | type,  | 
            ||
| 20 | startDate,  | 
            ||
| 21 | startsAllDay,  | 
            ||
| 22 | comment  | 
            ||
| 23 | } = command;  | 
            ||
| 24 | |||
| 25 | const leaveRequest = await this.leaveRequestRepository.findOneById(id);  | 
            ||
| 26 | |||
| 27 |     if (!leaveRequest) { | 
            ||
| 28 | throw new LeaveRequestNotFoundException();  | 
            ||
| 29 | }  | 
            ||
| 30 | |||
| 31 | leaveRequest.update(  | 
            ||
| 32 | type,  | 
            ||
| 33 | startDate,  | 
            ||
| 34 | startsAllDay,  | 
            ||
| 35 | endDate,  | 
            ||
| 36 | endsAllDay,  | 
            ||
| 37 | comment  | 
            ||
| 38 | );  | 
            ||
| 39 | await this.leaveRequestRepository.save(leaveRequest);  | 
            ||
| 40 | |||
| 41 | return leaveRequest.getId();  | 
            ||
| 42 | }  | 
            ||
| 44 |