Exemplo n.º 1
0
 /** PUT /polCandidates -> Updates an existing polCandidate. */
 @RequestMapping(
     value = "/polCandidates",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<PolCandidate> updatePolCandidate(
     @Valid @RequestBody PolCandidate polCandidate) throws URISyntaxException {
   log.debug("REST request to update PolCandidate : {}", polCandidate);
   if (polCandidate.getId() == null) {
     return createPolCandidate(polCandidate);
   }
   PolCandidate result = polCandidateRepository.save(polCandidate);
   polCandidateSearchRepository.save(result);
   return ResponseEntity.ok()
       .headers(
           HeaderUtil.createEntityUpdateAlert("polCandidate", polCandidate.getId().toString()))
       .body(result);
 }
Exemplo n.º 2
0
 /** POST /polCandidates -> Create a new polCandidate. */
 @RequestMapping(
     value = "/polCandidates",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<PolCandidate> createPolCandidate(
     @Valid @RequestBody PolCandidate polCandidate) throws URISyntaxException {
   log.debug("REST request to save PolCandidate : {}", polCandidate);
   if (polCandidate.getId() != null) {
     return ResponseEntity.badRequest()
         .headers(
             HeaderUtil.createFailureAlert(
                 "polCandidate", "idexists", "A new polCandidate cannot already have an ID"))
         .body(null);
   }
   PolCandidate result = polCandidateRepository.save(polCandidate);
   polCandidateSearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/polCandidates/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("polCandidate", result.getId().toString()))
       .body(result);
 }