use of uk.ac.bbsrc.tgac.miso.dto.TransferNotificationDto in project miso-lims by miso-lims.
the class TransferRestController method addNotification.
@PostMapping("/{transferId}/notifications")
@ResponseBody
public TransferNotificationDto addNotification(@PathVariable long transferId, @RequestBody TransferNotificationDto dto, @RequestParam(defaultValue = "false") boolean saveContact) throws IOException {
Transfer transfer = RestUtils.retrieve("Transfer", transferId, transferService);
TransferNotificationDto result = RestUtils.createObject("Notification", dto, from -> {
TransferNotification notification = Dtos.to(from);
notification.setTransfer(transfer);
return notification;
}, transferNotificationService, Dtos::asDto);
if (saveContact) {
Contact contact = new Contact();
contact.setName(result.getRecipientName());
contact.setEmail(result.getRecipientEmail());
contactService.create(contact);
}
return result;
}
Aggregations