Search in sources :

Example 1 with SpecialTaskDto

use of com.viadee.sonarQuest.dtos.SpecialTaskDto in project sonarQuest by viadee.

the class TaskController method updateTask.

@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public TaskDto updateTask(@PathVariable(value = "id") final Long id, @RequestBody final TaskDto taskDto) {
    TaskDto resultTaskDto = null;
    final Task task = this.taskRepository.findById(id);
    if (task != null) {
        task.setTitle(taskDto.getTitle());
        task.setGold(taskDto.getGold());
        task.setXp(taskDto.getXp());
        this.taskRepository.save(task);
        resultTaskDto = toTaskDto(task);
    }
    if (task instanceof SpecialTask) {
        ((SpecialTask) task).setMessage(((SpecialTaskDto) taskDto).getMessage());
        this.taskRepository.save(task);
        resultTaskDto = toTaskDto(task);
    }
    return resultTaskDto;
}
Also used : SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) Task(com.viadee.sonarQuest.entities.Task) SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) SpecialTaskDto(com.viadee.sonarQuest.dtos.SpecialTaskDto) TaskDto(com.viadee.sonarQuest.dtos.TaskDto) TaskDto.toTaskDto(com.viadee.sonarQuest.dtos.TaskDto.toTaskDto) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SpecialTaskDto (com.viadee.sonarQuest.dtos.SpecialTaskDto)1 TaskDto (com.viadee.sonarQuest.dtos.TaskDto)1 TaskDto.toTaskDto (com.viadee.sonarQuest.dtos.TaskDto.toTaskDto)1 SpecialTask (com.viadee.sonarQuest.entities.SpecialTask)1 Task (com.viadee.sonarQuest.entities.Task)1 CrossOrigin (org.springframework.web.bind.annotation.CrossOrigin)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1