use of com.kloia.eventapis.common.EventKey in project eventapis by kloiasoft.
the class CreateStockCommandHandler method execute.
@RequestMapping(value = "/stock/create", method = RequestMethod.POST)
@Command
public EventKey execute(@RequestBody CreateStockCommandDto dto) throws Exception {
StockCreatedEvent stockCreatedEvent = new StockCreatedEvent();
BeanUtils.copyProperties(dto, stockCreatedEvent);
EventKey eventKey = eventRepository.recordAndPublish(stockCreatedEvent);
try {
addStockCommandHandler.execute(eventKey.getEntityId(), new AddStockCommandDto(dto.getRemainingStock(), eventKey.getEntityId()));
} catch (Exception e) {
log.warn("Sub Command Failed:" + e.getMessage());
}
return eventKey;
}
Aggregations