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;
}
Aggregations