Ejemplo n.º 1
0
 /** PUT /prices -> Updates an existing price. */
 @RequestMapping(
     value = "/prices",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> update(@Valid @RequestBody Price price) throws URISyntaxException {
   log.debug("REST request to update Price : {}", price);
   if (price.getId() == null) {
     return create(price);
   }
   priceRepository.save(price);
   priceSearchRepository.save(price);
   return ResponseEntity.ok().build();
 }
Ejemplo n.º 2
0
 /** POST /prices -> Create a new price. */
 @RequestMapping(
     value = "/prices",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> create(@Valid @RequestBody Price price) throws URISyntaxException {
   log.debug("REST request to save Price : {}", price);
   if (price.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new price cannot already have an ID")
         .build();
   }
   priceRepository.save(price);
   priceSearchRepository.save(price);
   return ResponseEntity.created(new URI("/api/prices/" + price.getId())).build();
 }