use of com.kloia.sample.dto.command.AddStockCommandDto 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