use of com.bigcrowd.noticeBoard.dto.SupportDTO in project Notice-Board by FulvioFPimentel.
the class SupportController method save.
@PostMapping
public ResponseEntity<SupportDTO> save(@RequestBody SupportSaveDTO dto) {
try {
SupportDTO entity = supportService.saveSupport(dto);
URI uri = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(entity.getId()).toUri();
return ResponseEntity.created(uri).body(entity);
} catch (RuntimeException e) {
throw new ControllerNotFoundException("Not Found");
}
}
use of com.bigcrowd.noticeBoard.dto.SupportDTO in project Notice-Board by FulvioFPimentel.
the class SupportService method saveSupport.
@Transactional
public SupportDTO saveSupport(SupportSaveDTO dto) {
Meeting meeting = meetingRepository.getById(dto.getMeetingId());
Support support = new Support();
support.setMeeting(meeting);
for (DesignationSaveDTO desg : dto.getDesignations()) {
Assignment Assignment = assignmentRepository.getById(desg.getAssignment().getId());
Person person = personRepository.getById(desg.getPerson().getId());
Designation designation = new Designation();
designation.setAssignment(Assignment);
designation.setPerson(person);
designation = designationRepository.saveAndFlush(designation);
support.getDesignations().add(designation);
}
support = supportRepository.saveAndFlush(support);
return new SupportDTO(support, support.getDesignations());
}
Aggregations