if (!orderDetailsEvent.isEntityFound()) {
return OrderDeletedEvent.notFound(deleteOrderEvent.getKey());
}
Order order = Order.fromOrderDetails(orderDetailsEvent.getOrderDetails());
if (!order.canBeDeleted()) {
return OrderDeletedEvent.deletionForbidden(deleteOrderEvent.getKey(), order.toOrderDetails());
}
ordersPersistenceService.deleteOrder(deleteOrderEvent);
return new OrderDeletedEvent(deleteOrderEvent.getKey(), order.toOrderDetails());
}