From 39da24f7177b783c0e3dbb8a048d51d2a3ebadb8 Mon Sep 17 00:00:00 2001
From: L4168 <L4168@student.jamk.fi>
Date: Thu, 27 Jun 2019 11:44:51 +0300
Subject: [PATCH] added route for edit-task

---
 src/task/task.controller.ts | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/src/task/task.controller.ts b/src/task/task.controller.ts
index 6f272a0..db6be91 100644
--- a/src/task/task.controller.ts
+++ b/src/task/task.controller.ts
@@ -10,32 +10,27 @@ import {
 import { TaskService } from './task.service';
 import { Roles } from '../shared/roles.decorator';
 import { ValidationPipe } from '../shared/validation.pipe';
-import { TaskDTO } from './task.dto';
+import { CreateTaskDTO, EditTaskDTO } from './task.dto';
 
 @Controller('task')
 export class TaskController {
   constructor(private taskService: TaskService) {}
 
-  /*   @Post('new')
-  @UseGuards(new AuthGuard())
-  @UsePipes(new ValidationPipe())
-  async newGame(@User('id') person, @Body() body: GameDTO) {
-    return this.gameservice.createNewGame(person, body);
-  }
-
-  @Put(':id')
-  @Roles('admin')
-  @UsePipes(new ValidationPipe())
-  async editGame(@Param('id') id: string, @Body() body: GameDTO) {
-    return this.gameservice.editGame(id, body);
-  } */
-
   // creates a new task if the user has admin role in the game
   // :id is the id of the game
   @Post('new-task/:id')
-  //@Roles('admin')
+  @Roles('admin')
   @UsePipes(new ValidationPipe())
-  async newTask(@Param('id') id: string, @Body() task: TaskDTO) {
+  async newTask(@Param('id') id: string, @Body() task: CreateTaskDTO) {
     return this.taskService.newTask(task);
   }
+
+  // edits a created task if the user has admin role in the game
+  // :id is the id of the game
+  @Post('edit-task/:id')
+  @Roles('admin')
+  @UsePipes(new ValidationPipe())
+  async editTask(@Param('id') id: string, @Body() data: EditTaskDTO) {
+    return this.taskService.editTask(data);
+  }
 }
-- 
GitLab