use of com.kloia.sample.dto.event.ReserveStockEvent in project eventapis by kloiasoft.
the class ProcessOrderCommand method execute.
@Override
public EventKey execute(@RequestBody ProcessOrderCommandDto dto) throws Exception {
Orders order = orderQuery.queryEntity(dto.getOrderId());
if (order.getState() == OrderState.INITIAL) {
ReserveStockEvent reserveStockEvent = new ReserveStockEvent(order.getStockId(), order.getOrderAmount(), dto.getPaymentInformation());
log.info("Template account saved: " + dto);
return eventRepository.recordAndPublish(order, reserveStockEvent);
} else
throw new EventStoreException("Order state is not valid for this Operation: " + dto);
}
use of com.kloia.sample.dto.event.ReserveStockEvent in project eventapis by kloiasoft.
the class ProcessOrderCommand method process.
@RequestMapping(value = "/order/{orderId}/process", method = RequestMethod.POST)
@Command
public EventKey process(@PathVariable("orderId") String orderId, @RequestBody @Valid ProcessOrderCommandDto dto) throws Exception {
dto.setOrderId(orderId);
Orders order = orderQuery.queryEntity(dto.getOrderId());
if (order.getState() == OrderState.INITIAL) {
ReserveStockEvent reserveStockEvent = new ReserveStockEvent(order.getStockId(), order.getOrderAmount(), dto.getPaymentInformation());
log.info("Template account saved: " + dto);
return eventRepository.recordAndPublish(order, reserveStockEvent);
} else
throw new EventStoreException("Order state is not valid for this Operation: " + dto);
}
Aggregations