Commit 8f6b9676 authored by Alex Pinto's avatar Alex Pinto

fixing up bug in update endpoint

parent e726d4e3
......@@ -42,8 +42,11 @@ public class WarehouseController {
@CrossOrigin
@PutMapping(value = "/orders/{id}")
public Mono<WarehouseOrderResponse> updateOrder(@RequestBody WarehouseOrderResponse order, @PathVariable(value = "id") String id) {
return orderService.updateOrder(order, id);
public Mono<ResponseEntity> updateOrder(@RequestBody WarehouseOrderResponse order, @PathVariable(value = "id") String id) {
return orderService.updateOrder(order, id)
.map(updatedOrder -> (ResponseEntity.status(HttpStatus.OK).body(order)))
.cast(ResponseEntity.class)
.defaultIfEmpty(ResponseEntity.status(HttpStatus.NOT_FOUND).body(null));
}
@CrossOrigin
......
......@@ -45,9 +45,6 @@ public class WarehouseOrderService {
public Mono<WarehouseOrderResponse> updateOrder(WarehouseOrderResponse order, String id) {
return orderRepository.findById(id)
.doOnError(error -> {
throw new NotFoundException("Warehouse order of ID: " + id + " not found");
})
.flatMap(existingOrder -> {
existingOrder.setStatus(order.getStatus());
existingOrder.setModifiedAt(new Date(System.currentTimeMillis()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment