/** PUT /socios -> Updates an existing socio. */ @RequestMapping( value = "/socios", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Socio> update(@Valid @RequestBody Socio socio) throws URISyntaxException { log.debug("REST request to update Socio : {}", socio); if (socio.getId() == null) { return create(socio); } Socio result = socioRepository.save(socio); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert("socio", socio.getId().toString())) .body(result); }
/** POST /socios -> Create a new socio. */ @RequestMapping( value = "/socios", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Socio> create(@Valid @RequestBody Socio socio) throws URISyntaxException { log.debug("REST request to save Socio : {}", socio); if (socio.getId() != null) { return ResponseEntity.badRequest() .header("Failure", "A new socio cannot already have an ID") .body(null); } Socio result = socioRepository.save(socio); return ResponseEntity.created(new URI("/api/socios/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert("socio", result.getId().toString())) .body(result); }