| Total Complexity | 2 | 
| Total Lines | 31 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import { | 
            ||
| 16 | |||
| 17 | @Controller('events') | 
            ||
| 18 | @ApiUseTags('Event') | 
            ||
| 19 | @ApiBearerAuth()  | 
            ||
| 20 | @UseGuards(AuthGuard('bearer')) | 
            ||
| 21 | export class AddEventAction { | 
            ||
| 22 | constructor(  | 
            ||
| 23 |     @Inject('ICommandBus') | 
            ||
| 24 | private readonly commandBus: ICommandBus  | 
            ||
| 25 |   ) {} | 
            ||
| 26 | |||
| 27 | @Post()  | 
            ||
| 28 |   @ApiOperation({title: 'Add new event'}) | 
            ||
| 29 |   public async index(@Body() dto: EventDTO, @LoggedUser() user: User) { | 
            ||
| 30 |     try { | 
            ||
| 31 |       const {type, date, projectId, taskId, summary, time} = dto; | 
            ||
| 32 | const id = await this.commandBus.execute(  | 
            ||
| 33 | new AddEventCommand(  | 
            ||
| 34 | type,  | 
            ||
| 35 | user,  | 
            ||
| 36 | Number(time),  | 
            ||
| 37 | new Date(date),  | 
            ||
| 38 | projectId,  | 
            ||
| 39 | taskId,  | 
            ||
| 40 | summary  | 
            ||
| 41 | )  | 
            ||
| 42 | );  | 
            ||
| 43 | |||
| 44 |       return {id}; | 
            ||
| 45 |     } catch (e) { | 
            ||
| 46 | throw new BadRequestException(e.message);  | 
            ||
| 47 | }  | 
            ||
| 50 |